답안 #599891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599891 2022-07-20T06:13:05 Z starchan Baloni (COCI15_baloni) C++17
100 / 100
1072 ms 59448 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
set<in> cool;
signed main()
{
	fast();
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		cool.insert({-x, i});
	}
	int ans = 0;
	while(cool.size())
	{
		ans++;
		in fine = *cool.begin();
		int curr = fine.f;
		int index = fine.s;
		cool.erase(cool.begin());
		while(true)
		{
			if(cool.empty())
				break;
			auto it = cool.lower_bound({curr+1, index});
			if(it == cool.end())
				break;
			if((*it).f == curr+1)
			{
				curr = (*it).f;
				index = (*it).s;
				cool.erase(it);
			}
			else
				break;
		}
	}
	cout << ans;
	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 592 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 887 ms 53452 KB Output is correct
6 Correct 1072 ms 59448 KB Output is correct
7 Correct 800 ms 49020 KB Output is correct
8 Correct 780 ms 48336 KB Output is correct
9 Correct 818 ms 51240 KB Output is correct
10 Correct 876 ms 53180 KB Output is correct