답안 #739993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739993 2023-05-11T19:48:41 Z unexpectedbro Baloni (COCI15_baloni) C++14
100 / 100
204 ms 3896 KB
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long
#define pb push_back
#define all(a) a.begin(),a.end()
void solve()
{
	int n;cin>>n;
	int a[n];
	multiset<int>s;
	for(int i=0;i<n;i++){cin>>a[i];}
	ll ans=0;
	for(int i=0;i<n;i++){
		auto it=s.find(a[i]+1);
		if(it==s.end()){
			ans++;
		}
		else{
			s.erase(it);
		}
		s.insert(a[i]);
	}
	cout<<ans<<endl;
}
int main()
{
	fast
	int tc=1;
	//cin>>tc;

	while(tc--){
		solve();
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 162 ms 3412 KB Output is correct
6 Correct 204 ms 3896 KB Output is correct
7 Correct 172 ms 3300 KB Output is correct
8 Correct 161 ms 3144 KB Output is correct
9 Correct 164 ms 3376 KB Output is correct
10 Correct 180 ms 3412 KB Output is correct