Submission #1148184

#TimeUsernameProblemLanguageResultExecution timeMemory
1148184Faisal_SaqibInfinite Race (EGOI24_infiniterace2)C++20
29 / 100
23 ms416 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,q; cin>>n>>q; int pos[n]; for(int i=1;i<n;i++)pos[i]=1; pos[0]=0; int ans=0; while(q--) { int x; cin>>x; if(x>0) { // aneeqa overtook x if(pos[x]<pos[0]) // if x is behind then loop { ans++; } pos[0]=pos[x]+1; } else { // x<0 // this means -x over took aneeqa // if(pos[0]<pos[-x]) // 0 is behind then x loop // { // } pos[-x]=pos[0]+1; } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...