Submission #912426

#TimeUsernameProblemLanguageResultExecution timeMemory
912426speedcodeFountain (eJOI20_fountain)C++17
30 / 100
1515 ms3816 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; long long diameters[n+1]; long long capacities[n+1]; for(int i = 1; i <= n; i++) cin >> diameters[i] >> capacities[i]; int ri; long long vi; for(int i = 0; i < q; i++){ cin >> ri >> vi; long long lastDiameter = -1; int j = ri; for(j = ri; j <= n; ){ j++; if(lastDiameter >= diameters[j-1]) continue; lastDiameter = diameters[j-1]; if (vi <= capacities[j-1]){ j--; break; } else { vi -= capacities[j-1]; } } if(j <= n) cout << j << '\n'; else cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...