Submission #912426

# Submission time Handle Problem Language Result Execution time Memory
912426 2024-01-19T12:50:35 Z speedcode Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 3816 KB
#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 time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1515 ms 3816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Execution timed out 1515 ms 3816 KB Time limit exceeded
9 Halted 0 ms 0 KB -