제출 #1362425

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    int res = 0;
    unordered_set<int> ahead;
    for(int i = 0; i < q; i++){
        int e;
        cin >> e;
        if(e < 0){
            e = abs(e);
            if(ahead.find(e) != ahead.end()) ahead.erase(e);
        }
        else{
            // e = abs(e);
            if(ahead.find(e) != ahead.end()){
                res++;
                // cout << "lap after " << i << "\n";
                ahead = {};
            }
            ahead.insert(e);
        }
    }
    cout << res << "\n";
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…