Submission #844161

#TimeUsernameProblemLanguageResultExecution timeMemory
844161_Knyaz_Fountain (eJOI20_fountain)C++17
30 / 100
1517 ms4128 KiB
#include<bits/stdc++.h> using namespace std; int main() { long long N, Q; cin >> N >> Q; vector<pair<long long, long long>> Fountain; for(int i = 0; i < N; i++){ long long Di, Ci; cin >> Di >> Ci; Fountain.push_back({Di, Ci}); } for(int i = 0; i < Q; i++){ long long Ri, Vi; cin >> Ri >> Vi; long long LastD = 0; for(int j = Ri-1; j < N; j++){ if(Ri == N){ cout << (Vi > Fountain[j].second ? 0 : j) << '\n'; break; } if(Fountain[j].first > LastD){ Vi -= Fountain[j].second; LastD = Fountain[j].first; } if(Vi < 1){ cout << j + 1 << '\n'; break; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...