Submission #844161

# Submission time Handle Problem Language Result Execution time Memory
844161 2023-09-05T10:22:59 Z _Knyaz_ Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 4128 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 4 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1517 ms 4128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 4 ms 744 KB Output is correct
8 Execution timed out 1517 ms 4128 KB Time limit exceeded
9 Halted 0 ms 0 KB -