제출 #576402

#제출 시각아이디문제언어결과실행 시간메모리
576402emad234Fountain (eJOI20_fountain)C++17
30 / 100
1581 ms1348 KiB
#include <bits/stdc++.h> #define all(v) ((v).begin(),(v).end()) typedef long long ll; using namespace std; const int mod = 1e9 + 7; const int mxN = 2e6 + 1; pair<int,int> a[mxN]; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,q; cin >>n>>q; for(int i = 0;i < n;i++){ cin >>a[i].first>>a[i].second; } a[n].first = INT_MAX;a[n].second = INT_MAX; while(q--){ int r,v; cin >>r>>v; int prev = a[r - 1].first - 1; for(int i = r - 1;i <= n;i++){ if(a[i].first > prev){ prev = a[i].first; v -= a[i].second; } if(v <= 0){ if(i == n) cout<<0<<'\n'; else cout <<i + 1<<'\n'; break; } } } } // nice
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...