Submission #1086769

# Submission time Handle Problem Language Result Execution time Memory
1086769 2024-09-11T12:41:51 Z LOLOLO Baloni (COCI15_baloni) C++17
100 / 100
41 ms 4040 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define           s     second
#define           f     first
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 1e6 + 10;
int cnt[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (cnt[x + 1]) {
            cnt[x + 1]--;
        } else {
            ans++;
        }

        cnt[x]++;
    }

    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 476 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 38 ms 4040 KB Output is correct
6 Correct 41 ms 3920 KB Output is correct
7 Correct 33 ms 3156 KB Output is correct
8 Correct 32 ms 3000 KB Output is correct
9 Correct 38 ms 3408 KB Output is correct
10 Correct 34 ms 3520 KB Output is correct