Submission #83495

#TimeUsernameProblemLanguageResultExecution timeMemory
83495Noam527Baloni (COCI15_baloni)C++17
100 / 100
113 ms19884 KiB
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define debug cout << "ok" << endl
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7, inf = 1e9 + 7;
const ll hs = 199;
const ldb eps = 1e-9, pi = acos(-1);
using namespace std;

int n, x, a[1000005] = {}, ans = 0;

int main() {
	fast;
	cin >> n;
	while (n--) {
		cin >> x;
		if (a[x]) {
			a[x]--;
			a[x - 1]++;
		}
		else {
			a[x - 1]++;
			ans++;
		}
	}
	finish(ans);
}
#Verdict Execution timeMemoryGrader output
Fetching results...