제출 #1329062

#제출 시각아이디문제언어결과실행 시간메모리
1329062liptonekInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
14 ms1476 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n,q;
    cin>>n>>q;

    vector<bool> behind(n,false);
    vector<int> indices;

    long long total=0;

    for(int i=0; i<q; i++)
    {
        int x;
        cin>>x;

        if(x>0)
        {
            if(behind[x])
            {
                total++;

                for(int idx : indices)
                {
                    behind[idx]=false;
                }

                indices.clear();
            }

            if(!behind[x])
            {
                behind[x]=true;

                indices.push_back(x);
            }
        }
        else
        {
            int target=-x;

            behind[target]=false;
        }
    }

    cout<<total<<endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...