답안 #710306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710306 2023-03-15T06:56:45 Z ld_minh4354 Money (IZhO17_money) C++17
100 / 100
1455 ms 112144 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define int long long
#define fi first
#define se second
#define pb push_back
#define debug(x) cout<<#x<<": "<<x<<"\n"
 
bool comp(vector<int> v1, vector<int> v2)
{
	return v1[0]<v2[0];
}
 
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//	freopen("input.000","r",stdin);
//	freopen("output.000","w",stdout);
//	srand((unsigned)time(NULL));
//	rand()
	
	int n,i,a[1000005],ans,m,r,pos;
	vector<int> v[1000005];
	ordered_set s;
	
	cin>>n;a[0]=0;
	for (i=1;i<n+1;i++) cin>>a[i];
	
	m=1;
	for (i=1;i<n+1;i++)
	{
		if (a[i-1]>a[i]) m++;
		v[m].pb(a[i]);
	}
//	sort(v+1,v+m+1,comp);
	
//	for (i=1;i<m+1;i++)
//	{
//		cout<<i<<": ";
//		for (auto val:v[i]) cout<<val<<" ";
//		cout<<"\n";
//	}
	
	ans=m;
	s.insert(0);s.insert(1e7);
	for (i=1;i<m+1;i++)
	{
		pos=s.order_of_key(v[i][0]+1);
		r=*s.find_by_order(pos);
		
		for (auto val:v[i]) if (val>r)
		{
			ans++;
			pos=s.order_of_key(val+1);
			r=*s.find_by_order(pos);
		}
		
		for (auto val:v[i]) s.insert(val);
	}
	
	cout<<ans;
}
 
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31572 KB Output is correct
2 Correct 18 ms 31532 KB Output is correct
3 Correct 20 ms 31500 KB Output is correct
4 Correct 17 ms 31548 KB Output is correct
5 Correct 18 ms 31616 KB Output is correct
6 Correct 18 ms 31572 KB Output is correct
7 Correct 19 ms 31572 KB Output is correct
8 Correct 21 ms 31572 KB Output is correct
9 Correct 19 ms 31572 KB Output is correct
10 Correct 20 ms 31628 KB Output is correct
11 Correct 19 ms 31548 KB Output is correct
12 Correct 19 ms 31496 KB Output is correct
13 Correct 19 ms 31560 KB Output is correct
14 Correct 20 ms 31608 KB Output is correct
15 Correct 18 ms 31572 KB Output is correct
16 Correct 19 ms 31524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31572 KB Output is correct
2 Correct 18 ms 31532 KB Output is correct
3 Correct 20 ms 31500 KB Output is correct
4 Correct 17 ms 31548 KB Output is correct
5 Correct 18 ms 31616 KB Output is correct
6 Correct 18 ms 31572 KB Output is correct
7 Correct 19 ms 31572 KB Output is correct
8 Correct 21 ms 31572 KB Output is correct
9 Correct 19 ms 31572 KB Output is correct
10 Correct 20 ms 31628 KB Output is correct
11 Correct 19 ms 31548 KB Output is correct
12 Correct 19 ms 31496 KB Output is correct
13 Correct 19 ms 31560 KB Output is correct
14 Correct 20 ms 31608 KB Output is correct
15 Correct 18 ms 31572 KB Output is correct
16 Correct 19 ms 31524 KB Output is correct
17 Correct 17 ms 31520 KB Output is correct
18 Correct 18 ms 31572 KB Output is correct
19 Correct 19 ms 31572 KB Output is correct
20 Correct 22 ms 31564 KB Output is correct
21 Correct 22 ms 31528 KB Output is correct
22 Correct 25 ms 31620 KB Output is correct
23 Correct 21 ms 31536 KB Output is correct
24 Correct 19 ms 31632 KB Output is correct
25 Correct 20 ms 31572 KB Output is correct
26 Correct 21 ms 31624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31572 KB Output is correct
2 Correct 18 ms 31532 KB Output is correct
3 Correct 20 ms 31500 KB Output is correct
4 Correct 17 ms 31548 KB Output is correct
5 Correct 18 ms 31616 KB Output is correct
6 Correct 18 ms 31572 KB Output is correct
7 Correct 19 ms 31572 KB Output is correct
8 Correct 21 ms 31572 KB Output is correct
9 Correct 19 ms 31572 KB Output is correct
10 Correct 20 ms 31628 KB Output is correct
11 Correct 19 ms 31548 KB Output is correct
12 Correct 19 ms 31496 KB Output is correct
13 Correct 19 ms 31560 KB Output is correct
14 Correct 20 ms 31608 KB Output is correct
15 Correct 18 ms 31572 KB Output is correct
16 Correct 19 ms 31524 KB Output is correct
17 Correct 17 ms 31520 KB Output is correct
18 Correct 18 ms 31572 KB Output is correct
19 Correct 19 ms 31572 KB Output is correct
20 Correct 22 ms 31564 KB Output is correct
21 Correct 22 ms 31528 KB Output is correct
22 Correct 25 ms 31620 KB Output is correct
23 Correct 21 ms 31536 KB Output is correct
24 Correct 19 ms 31632 KB Output is correct
25 Correct 20 ms 31572 KB Output is correct
26 Correct 21 ms 31624 KB Output is correct
27 Correct 18 ms 31620 KB Output is correct
28 Correct 20 ms 31528 KB Output is correct
29 Correct 21 ms 31576 KB Output is correct
30 Correct 22 ms 31624 KB Output is correct
31 Correct 23 ms 31616 KB Output is correct
32 Correct 22 ms 31628 KB Output is correct
33 Correct 24 ms 31624 KB Output is correct
34 Correct 19 ms 31572 KB Output is correct
35 Correct 19 ms 31612 KB Output is correct
36 Correct 18 ms 31632 KB Output is correct
37 Correct 19 ms 31700 KB Output is correct
38 Correct 18 ms 31572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31572 KB Output is correct
2 Correct 18 ms 31532 KB Output is correct
3 Correct 20 ms 31500 KB Output is correct
4 Correct 17 ms 31548 KB Output is correct
5 Correct 18 ms 31616 KB Output is correct
6 Correct 18 ms 31572 KB Output is correct
7 Correct 19 ms 31572 KB Output is correct
8 Correct 21 ms 31572 KB Output is correct
9 Correct 19 ms 31572 KB Output is correct
10 Correct 20 ms 31628 KB Output is correct
11 Correct 19 ms 31548 KB Output is correct
12 Correct 19 ms 31496 KB Output is correct
13 Correct 19 ms 31560 KB Output is correct
14 Correct 20 ms 31608 KB Output is correct
15 Correct 18 ms 31572 KB Output is correct
16 Correct 19 ms 31524 KB Output is correct
17 Correct 17 ms 31520 KB Output is correct
18 Correct 18 ms 31572 KB Output is correct
19 Correct 19 ms 31572 KB Output is correct
20 Correct 22 ms 31564 KB Output is correct
21 Correct 22 ms 31528 KB Output is correct
22 Correct 25 ms 31620 KB Output is correct
23 Correct 21 ms 31536 KB Output is correct
24 Correct 19 ms 31632 KB Output is correct
25 Correct 20 ms 31572 KB Output is correct
26 Correct 21 ms 31624 KB Output is correct
27 Correct 18 ms 31620 KB Output is correct
28 Correct 20 ms 31528 KB Output is correct
29 Correct 21 ms 31576 KB Output is correct
30 Correct 22 ms 31624 KB Output is correct
31 Correct 23 ms 31616 KB Output is correct
32 Correct 22 ms 31628 KB Output is correct
33 Correct 24 ms 31624 KB Output is correct
34 Correct 19 ms 31572 KB Output is correct
35 Correct 19 ms 31612 KB Output is correct
36 Correct 18 ms 31632 KB Output is correct
37 Correct 19 ms 31700 KB Output is correct
38 Correct 18 ms 31572 KB Output is correct
39 Correct 88 ms 39416 KB Output is correct
40 Correct 164 ms 45048 KB Output is correct
41 Correct 82 ms 37752 KB Output is correct
42 Correct 74 ms 37624 KB Output is correct
43 Correct 57 ms 35848 KB Output is correct
44 Correct 176 ms 48404 KB Output is correct
45 Correct 160 ms 48000 KB Output is correct
46 Correct 169 ms 48376 KB Output is correct
47 Correct 141 ms 45512 KB Output is correct
48 Correct 152 ms 46580 KB Output is correct
49 Correct 632 ms 73388 KB Output is correct
50 Correct 575 ms 72864 KB Output is correct
51 Correct 687 ms 73548 KB Output is correct
52 Correct 669 ms 72716 KB Output is correct
53 Correct 629 ms 73108 KB Output is correct
54 Correct 616 ms 72784 KB Output is correct
55 Correct 1339 ms 111924 KB Output is correct
56 Correct 1381 ms 111984 KB Output is correct
57 Correct 1363 ms 112028 KB Output is correct
58 Correct 1455 ms 112128 KB Output is correct
59 Correct 1371 ms 112060 KB Output is correct
60 Correct 1353 ms 112124 KB Output is correct
61 Correct 1331 ms 112028 KB Output is correct
62 Correct 1265 ms 112144 KB Output is correct