Submission #208387

# Submission time Handle Problem Language Result Execution time Memory
208387 2020-03-11T05:44:49 Z ArKCa Baloni (COCI15_baloni) C++17
100 / 100
295 ms 7416 KB
#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 time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 288 ms 7064 KB Output is correct
6 Correct 295 ms 7416 KB Output is correct
7 Correct 236 ms 5992 KB Output is correct
8 Correct 243 ms 6008 KB Output is correct
9 Correct 265 ms 6520 KB Output is correct
10 Correct 266 ms 6520 KB Output is correct