Submission #641925

#TimeUsernameProblemLanguageResultExecution timeMemory
641925ivazivaFountain (eJOI20_fountain)C++14
0 / 100
273 ms10640 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 100010 vector<long long> adj[MAXN]; bool pos[MAXN]; long long d[MAXN],c[MAXN]; long long n,q; long long br; void dfs(long long node,long long vv) { pos[node]=true; vv=-c[node]; if (vv<=0) { br=node; return; } long long s=adj[node].size(); for (long long i=0;i<s;i++) { long long sled=adj[node][i]; if (pos[sled]==false) dfs(sled,vv); } } int main() { cin>>n>>q; for (long long i=1;i<=n;i++) cin>>d[i]>>c[i]; for (long long i=1;i<n;i++) adj[i].push_back(i+1); for (long long i=1;i<=q;i++) { long long r,v; cin>>r>>v; br=0; dfs(r,v); cout<<br<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...