Submission #162699

# Submission time Handle Problem Language Result Execution time Memory
162699 2019-11-09T11:25:21 Z Leonardo_Paes Baloni (COCI15_baloni) C++17
100 / 100
85 ms 3960 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e6+10;

int h[maxn], mark[maxn];

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

    int n, ans=0;

    cin >> n;

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

    for(int i=n; i>=1; i--){
        if(mark[h[i]-1]){
            mark[h[i]-1]--;
        }
        else{
            ans++;
        }
        mark[h[i]]++;
    }

    cout << ans << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 85 ms 3448 KB Output is correct
6 Correct 85 ms 3960 KB Output is correct
7 Correct 69 ms 3192 KB Output is correct
8 Correct 65 ms 3188 KB Output is correct
9 Correct 76 ms 3276 KB Output is correct
10 Correct 76 ms 3520 KB Output is correct