Submission #208387

#TimeUsernameProblemLanguageResultExecution timeMemory
208387ArKCaBaloni (COCI15_baloni)C++17
100 / 100
295 ms7416 KiB
#include<bits/stdc++.h> using namespace std; int arr[1000005],cnt[1000005],ans; int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n; cin>>n; for(int i=0;i<n;i++){ cin>>arr[i]; } for(int i=n-1;i>=0;i--){ if(cnt[arr[i]-1]==0){ ans++; cnt[arr[i]]++; } else{ cnt[arr[i]-1]--; cnt[arr[i]]++; } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...