Submission #769909

# Submission time Handle Problem Language Result Execution time Memory
769909 2023-06-30T13:01:36 Z PAndaS Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 2156 KB
#include<bits/stdc++.h>

using namespace std;

long find_next(vector<long> d, long i){
    long orig = d[i];
    for(int j = i + 1; j < d.size(); j++) if(d[j] > orig) return j;
    return -1;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long n, q;
    cin >> n >> q;
    vector<long> d(n);
    vector<int> c(n);
    for(long i = 0; i < n; i++) cin >> d[i] >> c[i];
    long r, v; long tmp;
    for(long i = 0; i < q; i++){
        cin >> r >> v;
        r--;
        while(v > 0 || r != -1){
            v -= c[r];
            if(v <= 0){ cout << r + 1 << '\n'; break;}
            r = find_next(d, r);
            if(r == -1){cout << 0 << '\n'; break;}
        }
    }
    return 0;
}

Compilation message

fountain.cpp: In function 'long int find_next(std::vector<long int>, long int)':
fountain.cpp:7:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int j = i + 1; j < d.size(); j++) if(d[j] > orig) return j;
      |                        ~~^~~~~~~~~~
fountain.cpp: In function 'int main()':
fountain.cpp:20:21: warning: unused variable 'tmp' [-Wunused-variable]
   20 |     long r, v; long tmp;
      |                     ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 71 ms 340 KB Output is correct
6 Correct 25 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1573 ms 2156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 71 ms 340 KB Output is correct
6 Correct 25 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Execution timed out 1573 ms 2156 KB Time limit exceeded
9 Halted 0 ms 0 KB -