| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1148184 | Faisal_Saqib | Infinite Race (EGOI24_infiniterace2) | C++20 | 23 ms | 416 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 time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
