제출 #1332812

#제출 시각아이디문제언어결과실행 시간메모리
1332812Zone_zoneeBaloni (COCI15_baloni)C++20
0 / 100
95 ms196608 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;

int a[N];
queue<int> q[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        q[a[i]].push(i);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(q[a[i]].empty() || q[a[i]].front() != i) continue;
        while(!q[a[i]].empty() && q[a[i]].front() >= i) q[a[i]--].pop();
        ans++;
    }
    cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...