Submission #908938

# Submission time Handle Problem Language Result Execution time Memory
908938 2024-01-17T02:39:59 Z PlayVoltz Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 3872 KB
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <iostream>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back

vector<int> val, par;

int32_t main(){
	int n, q, a, b;
	cin>>n>>q;
	stack<pii> st;
	val.resize(n+1, LLONG_MAX/2);
	par.resize(n+1, 0);
	for (int i=1; i<=n; ++i){
		cin>>a>>val[i];
		while (!st.empty()&&st.top().first<a)par[st.top().second]=i, st.pop();
		st.push(mp(a, i));
	}
	while (q--){
		cin>>a>>b;
		while (val[a]<b){
			b-=val[a];
			a=par[a];
		}
		cout<<a<<"\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1537 ms 3872 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 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Execution timed out 1537 ms 3872 KB Time limit exceeded
9 Halted 0 ms 0 KB -