제출 #1351329

#제출 시각아이디문제언어결과실행 시간메모리
1351329mxhrvsInfinite Race (EGOI24_infiniterace2)C++20
0 / 100
131 ms19948 KiB
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int x[k+1];
    set<int> s;
    map<int,int> mp;
    int ans = 0;
    for(int i = 1; i <= k; i ++){
        cin >> x[i];
        if(x[i] > 0 and s.find(-x[i]) != s.end()) s.erase(-x[i]);
        else if (x[i] > 0 and s.find(-x[i]) == s.end() and mp[x[i]] > ans and x[i] != x[i - 1]) ans ++;
        else if (x[i] > 0 and s.find(-x[i]) == s.end() and mp[x[i]] >= ans and x[i] == x[i-1] ) ans ++;
        mp[x[i]] ++;
        s.insert(x[i]);
    }
    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...