Submission #91173

# Submission time Handle Problem Language Result Execution time Memory
91173 2018-12-26T12:46:39 Z davitmarg Money (IZhO17_money) C++17
45 / 100
1500 ms 51724 KB
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>  
#include <fstream>  
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;
int n,ans,a[1000006],l;
set<int> s;
stack<int> st;
set<int>::iterator it;
int main()
{
	cin >> n;
	ans = 1;
	for (int i = 1; i <= n; i++)
		scanf("%d", a+i);
	s.insert(0);
	it = s.upper_bound(l);
	for (int i = 1; i <= n; i++)
	{
		if ((a[i] < a[i - 1]) || it != s.end() && (*it) < a[i] )
		{
			l = a[i];
			ans++;
			while (!st.empty())
			{
				s.insert(st.top());
				st.pop();
			}
			it = s.upper_bound(l);
		}
		st.push(a[i]);
	}

	cout << ans << endl;
	return 0;
}

/*

6
1 3 5 2 4 6

*/

Compilation message

money.cpp: In function 'int main()':
money.cpp:40:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if ((a[i] < a[i - 1]) || it != s.end() && (*it) < a[i] )
                            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
money.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+i);
   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 1 ms 528 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 1 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 2 ms 560 KB Output is correct
15 Correct 2 ms 560 KB Output is correct
16 Correct 2 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 1 ms 528 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 1 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 2 ms 560 KB Output is correct
15 Correct 2 ms 560 KB Output is correct
16 Correct 2 ms 560 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 560 KB Output is correct
19 Correct 2 ms 560 KB Output is correct
20 Correct 2 ms 608 KB Output is correct
21 Correct 2 ms 608 KB Output is correct
22 Correct 2 ms 608 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 620 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 1 ms 528 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 1 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 2 ms 560 KB Output is correct
15 Correct 2 ms 560 KB Output is correct
16 Correct 2 ms 560 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 560 KB Output is correct
19 Correct 2 ms 560 KB Output is correct
20 Correct 2 ms 608 KB Output is correct
21 Correct 2 ms 608 KB Output is correct
22 Correct 2 ms 608 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 620 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 636 KB Output is correct
28 Correct 2 ms 636 KB Output is correct
29 Correct 2 ms 636 KB Output is correct
30 Correct 2 ms 636 KB Output is correct
31 Correct 2 ms 636 KB Output is correct
32 Correct 2 ms 636 KB Output is correct
33 Correct 2 ms 636 KB Output is correct
34 Correct 2 ms 636 KB Output is correct
35 Correct 2 ms 636 KB Output is correct
36 Correct 2 ms 636 KB Output is correct
37 Correct 2 ms 636 KB Output is correct
38 Correct 2 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 1 ms 528 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 1 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 544 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 560 KB Output is correct
13 Correct 2 ms 560 KB Output is correct
14 Correct 2 ms 560 KB Output is correct
15 Correct 2 ms 560 KB Output is correct
16 Correct 2 ms 560 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 560 KB Output is correct
19 Correct 2 ms 560 KB Output is correct
20 Correct 2 ms 608 KB Output is correct
21 Correct 2 ms 608 KB Output is correct
22 Correct 2 ms 608 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 620 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 636 KB Output is correct
28 Correct 2 ms 636 KB Output is correct
29 Correct 2 ms 636 KB Output is correct
30 Correct 2 ms 636 KB Output is correct
31 Correct 2 ms 636 KB Output is correct
32 Correct 2 ms 636 KB Output is correct
33 Correct 2 ms 636 KB Output is correct
34 Correct 2 ms 636 KB Output is correct
35 Correct 2 ms 636 KB Output is correct
36 Correct 2 ms 636 KB Output is correct
37 Correct 2 ms 636 KB Output is correct
38 Correct 2 ms 636 KB Output is correct
39 Correct 66 ms 2428 KB Output is correct
40 Correct 120 ms 3708 KB Output is correct
41 Correct 54 ms 3708 KB Output is correct
42 Correct 54 ms 3708 KB Output is correct
43 Correct 41 ms 3708 KB Output is correct
44 Correct 145 ms 4504 KB Output is correct
45 Correct 143 ms 4608 KB Output is correct
46 Correct 145 ms 4608 KB Output is correct
47 Correct 125 ms 4608 KB Output is correct
48 Correct 135 ms 4608 KB Output is correct
49 Correct 678 ms 23148 KB Output is correct
50 Correct 622 ms 23148 KB Output is correct
51 Correct 649 ms 23148 KB Output is correct
52 Correct 649 ms 23292 KB Output is correct
53 Correct 641 ms 23292 KB Output is correct
54 Correct 531 ms 23292 KB Output is correct
55 Correct 1226 ms 51524 KB Output is correct
56 Correct 1404 ms 51524 KB Output is correct
57 Correct 1267 ms 51552 KB Output is correct
58 Correct 1222 ms 51584 KB Output is correct
59 Correct 1169 ms 51724 KB Output is correct
60 Correct 1380 ms 51724 KB Output is correct
61 Execution timed out 1553 ms 51724 KB Time limit exceeded
62 Halted 0 ms 0 KB -