# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
990634 | _Knyaz_ | Fountain (eJOI20_fountain) | C++17 | 1546 ms | 3604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+1;
void in(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
vector<pair<int, int>> Fountain;
int main()
{
//in();
int N, Q; cin >> N >> Q;
for(int i = 0; i < N; i++){
int Di, Ci; cin >> Di >> Ci;
Fountain.push_back(make_pair(Di, Ci));
}
int Ri, Vi, Mn;
for(int i = 0; i < Q; i++){
cin >> Ri >> Vi;
Mn = Fountain[Ri - 1].first - 1;
for(int j = Ri - 1; j < N; j++){
if(Fountain[j].second >= Vi && Fountain[j].first > Mn){
cout << j + 1 << '\n';
Vi = 0;
break;
}
else if(Fountain[j].first > Mn){
Vi -= Fountain[j].second;
Mn = Fountain[j].first;
}
}
if(Vi > 0) cout << 0 << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |