Submission #120034

#TimeUsernameProblemLanguageResultExecution timeMemory
120034ClementimeBaloni (COCI15_baloni)C++17
0 / 100
204 ms18808 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, l, r) for(ll i = l; i <= r; i++) const ll MAX = 1000005; ll a[MAX], dp[MAX]; bool used[MAX]; int main(){ ll n; cin >> n; memset(used, false, sizeof used); FOR(i, 1, n){ cin >> a[i]; } dp[1] = 1; used[a[1]] = true; FOR(i, 2, n){ if(used[a[i] + 1]) dp[i] = dp[i - 1]; else dp[i] = dp[i - 1] + 1; used[a[i]] = true; } cout << dp[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...