Submission #646141

# Submission time Handle Problem Language Result Execution time Memory
646141 2022-09-28T18:48:52 Z Adominator Baloni (COCI15_baloni) C++17
100 / 100
56 ms 7764 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define ar array
#define vo vector
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()

#define rep(i, a, b) for(ll i=(a); i<(b); i++) 
#define repd(i, a, b) for(ll i=(a); i>=(b); i--) 

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int n;
    cin >> n;

    int cnt[int(1e6)+1]{};
    rep(i, 0, n) {
        int h;
        cin >> h;

        cnt[h]++;
        if(h+1<=int(1e6+1)&&cnt[h+1]) 
            cnt[h+1]--;
    }

    int ans=0;
    rep(i, 1, 1e6+1) 
        ans+=cnt[i];

    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 3 ms 4236 KB Output is correct
3 Correct 4 ms 4248 KB Output is correct
4 Correct 4 ms 4244 KB Output is correct
5 Correct 56 ms 7756 KB Output is correct
6 Correct 55 ms 7764 KB Output is correct
7 Correct 44 ms 7020 KB Output is correct
8 Correct 46 ms 7080 KB Output is correct
9 Correct 50 ms 7408 KB Output is correct
10 Correct 50 ms 7248 KB Output is correct