Submission #98757

# Submission time Handle Problem Language Result Execution time Memory
98757 2019-02-25T16:01:01 Z M_H_H_7 Baloni (COCI15_baloni) C++14
100 / 100
138 ms 30988 KB
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e6 + 8;
ll const INF  = 1e12 + 8;
ll const delta = 1000000007;
ll a[MAXN];
vll last[MAXN];
int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    for(ll i = 1;i <= n;i++)cin >> a[i];
    ll ans = 0;
    for(ll i = 1;i <= n;i++)
    {
        ll t = a[i];
        if(!last[t + 1].size())
        {
            ans++;
        }
        else
        {
            last[t + 1].pop_back();
        }
        last[t].pb(i);
    }
    cout << ans;
    return 0;
}
//Written by M_H_H_7
# Verdict Execution time Memory Grader output
1 Correct 27 ms 23828 KB Output is correct
2 Correct 27 ms 23928 KB Output is correct
3 Correct 30 ms 23924 KB Output is correct
4 Correct 25 ms 23936 KB Output is correct
5 Correct 107 ms 30328 KB Output is correct
6 Correct 138 ms 30988 KB Output is correct
7 Correct 87 ms 29688 KB Output is correct
8 Correct 101 ms 29764 KB Output is correct
9 Correct 128 ms 29920 KB Output is correct
10 Correct 115 ms 30328 KB Output is correct