Submission #448044

# Submission time Handle Problem Language Result Execution time Memory
448044 2021-07-28T16:24:22 Z fuad27 Fountain (eJOI20_fountain) C++14
0 / 100
1500 ms 2916 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
int main () {
	int n, q;
	cin >> n >> q;
	vector<int> d;
	vector<int> c;
	for(int i = 0;i<n;i++) {
		int a, b;
		cin >> a >> b;
		d.push_back(a);
		c.push_back(b);
	}
	while(q--) {
		int i, v;
		cin >> i >> v;
		i--;
		int prev = i;
		while(v > 0 and i < n) {
			if(prev == i)v-=c[i];
			else if(d[i] >= d[prev]) {
				v-=c[i];
				prev = i;
			}
			i++;
		}
		if(v > 0)cout<<0<<endl;
		else cout<<i<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1594 ms 2916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -