Submission #31640

# Submission time Handle Problem Language Result Execution time Memory
31640 2017-08-30T07:47:11 Z long10024070 Baloni (COCI15_baloni) C++11
100 / 100
73 ms 9988 KB
#include <iostream>
#include <cstdio>

using namespace std;
const string TASK = "Baloni";

int n,h[(int)1e6+1],c[(int)1e6+1],res;

void Enter()
{
    cin >> n;
    for (int i=1;i<=n;++i)
        cin >> h[i];
}

void Init()
{

}

void Solve()
{
    res = 0;
    for (int i=1;i<=n;++i)
        if (c[h[i]] == 0) {
            ++res;
            ++c[h[i]-1];
        }
        else {
            --c[h[i]];
            ++c[h[i]-1];
        }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen((TASK+".INP").c_str(),"r",stdin);
    //freopen((TASK+".OUT").c_str(),"w",stdout);

    Enter();
    Init();
    Solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9988 KB Output is correct
2 Correct 0 ms 9988 KB Output is correct
3 Correct 0 ms 9988 KB Output is correct
4 Correct 0 ms 9988 KB Output is correct
5 Correct 69 ms 9988 KB Output is correct
6 Correct 73 ms 9988 KB Output is correct
7 Correct 49 ms 9988 KB Output is correct
8 Correct 59 ms 9988 KB Output is correct
9 Correct 73 ms 9988 KB Output is correct
10 Correct 73 ms 9988 KB Output is correct