제출 #710567

#제출 시각아이디문제언어결과실행 시간메모리
710567ToroTNBaloni (COCI15_baloni)C++14
100 / 100
196 ms7328 KiB
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],hsh[1000005],cnt=0;
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)cin >> a[i];
    for(int i=n;i>=1;i--)
    {
        if(hsh[a[i]-1]==0)
        {
            ++cnt;
        }else
        {
            --hsh[a[i]-1];
        }
        ++hsh[a[i]];
    }
    printf("%d\n",cnt);
}
#Verdict Execution timeMemoryGrader output
Fetching results...