답안 #92714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92714 2019-01-04T11:13:37 Z GioChkhaidze Money (IZhO17_money) C++14
100 / 100
1386 ms 55292 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define Pb push_back
using namespace std;
int n,a[1000006],fix[1000006],Ans,Ps;
 
pair < int , int > p [1000006]; 
 
vector < vector < pair < int , int > > > V;
vector < pair < int , int > > v,Z;
 
set < int > st; 
 
void go(int x,int idx)
{
	int ko=0,ID=idx;
	Ans++;
	
	fix[idx]=1;

	for (int i=idx+1; i<=n; i++)
	{
		if (a[i]<a[i-1]) break;
		
		if (st.upper_bound(x)==st.end() || a[i]<=*st.upper_bound(x))
		{
			fix[i]=1;
			ID=i;
		}
			else break;
	}
	
	for (int i=idx; i<=ID; i++)
		st.insert(a[i]);
}
 
main ()
{
	ios::sync_with_stdio(false);
	
	cin>>n;
	
	for (int i=1; i<=n; i++)
		cin>>a[i];
				
	for (int i=1; i<=n; i++)
	{
		if (!fix[i]) go(a[i],i);
		/*
		for (int j=1; j<=n; j++)
			cout<<fix[j]<<" ";
		cout<<endl;*/
	}
		
	cout<<Ans<<endl;
}
/*
 
10
1 4 6 2 3 7 10 8 9 5
| 1 4 6 | 2 3 | 7 10 | 8 9 | 5 |
 
6
3 6 4 5 1 2
 
5 
1 3 5 2 4
 
8
1 3 2 4 5 8 7 6
 
5
2 3 5 3 5
 
4
2 2 2 2
 
5
2 4 5 2 5
 
5
2 5 2 4 5


4
3 2 3 2 

*/

Compilation message

money.cpp: In function 'void go(int, int)':
money.cpp:17:6: warning: unused variable 'ko' [-Wunused-variable]
  int ko=0,ID=idx;
      ^~
money.cpp: At global scope:
money.cpp:38:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main ()
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 1 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 1 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 1 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 1 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 2 ms 372 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 60 ms 4064 KB Output is correct
40 Correct 104 ms 6576 KB Output is correct
41 Correct 50 ms 3436 KB Output is correct
42 Correct 48 ms 3064 KB Output is correct
43 Correct 34 ms 2296 KB Output is correct
44 Correct 126 ms 8156 KB Output is correct
45 Correct 127 ms 8248 KB Output is correct
46 Correct 128 ms 8300 KB Output is correct
47 Correct 110 ms 8132 KB Output is correct
48 Correct 116 ms 8232 KB Output is correct
49 Correct 589 ms 26624 KB Output is correct
50 Correct 560 ms 26648 KB Output is correct
51 Correct 616 ms 26704 KB Output is correct
52 Correct 574 ms 26628 KB Output is correct
53 Correct 578 ms 26756 KB Output is correct
54 Correct 586 ms 26772 KB Output is correct
55 Correct 1386 ms 55260 KB Output is correct
56 Correct 1368 ms 55288 KB Output is correct
57 Correct 1314 ms 55160 KB Output is correct
58 Correct 1328 ms 55240 KB Output is correct
59 Correct 1386 ms 55288 KB Output is correct
60 Correct 1363 ms 55260 KB Output is correct
61 Correct 1339 ms 55160 KB Output is correct
62 Correct 1292 ms 55292 KB Output is correct