Submission #469033

# Submission time Handle Problem Language Result Execution time Memory
469033 2021-08-30T12:55:16 Z ala2 Baloni (COCI15_baloni) C++14
100 / 100
225 ms 7392 KB
#include <iostream>

using namespace std;
int a[1001000];
int v[1001000];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    v[a[0]]=1;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(v[a[i]+1])
        {
            v[a[i]+1]--;
            v[a[i]]++;
        }
        else
        {
           // cout<<"            "<<i<<endl;
            ans++;
            v[a[i]]++;
        }
        //for(int i=0;i<n;i++)
        //    cout<<v[i]<<" ";
       // cout<<endl;
       // cout<<endl;

    }
    cout<<ans+1<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 214 ms 6980 KB Output is correct
6 Correct 225 ms 7392 KB Output is correct
7 Correct 181 ms 5988 KB Output is correct
8 Correct 176 ms 5828 KB Output is correct
9 Correct 199 ms 6480 KB Output is correct
10 Correct 204 ms 6596 KB Output is correct