Submission #229870

# Submission time Handle Problem Language Result Execution time Memory
229870 2020-05-06T22:18:16 Z pedroslrey Money (IZhO17_money) C++14
100 / 100
1160 ms 62172 KB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using pii = pair<int, int>;
using lli = long long int;

#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define fi first
#define se second
#define all(xs) xs.begin(), xs.end()

const int INF = 1e9;

vector<int> xs;
vector<int> ys;
 
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		xs.pb(x);
	}
 
	ys.push_back(xs[0]);
	for (int i = 1; i < n; ++i)
		if (xs[i] != xs[i-1])
			ys.push_back(xs[i]);

	int m = (int)ys.size();

	set<int> s; 
	s.insert(INF);
	int total = 1;
	int k = 0;
 
	for (int i = 0; i < m-1; ++i) {
		if ((ys[i] > ys[i+1]) || (ys[i] < ys[i+1] && *s.lower_bound(ys[i]-k+1) < ys[i+1])){
			k = 0;
			++total;
		}
		else k = 1;
		s.insert(ys[i]);
	}
 
	printf("%d\n", total);
}

Compilation message

money.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
money.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
money.cpp: In function 'int main()':
money.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
money.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 6 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 4 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 6 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 4 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 4 ms 256 KB Output is correct
35 Correct 5 ms 256 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 6 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 4 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 4 ms 256 KB Output is correct
35 Correct 5 ms 256 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 88 ms 8548 KB Output is correct
40 Correct 158 ms 14940 KB Output is correct
41 Correct 70 ms 7528 KB Output is correct
42 Correct 71 ms 7012 KB Output is correct
43 Correct 52 ms 4460 KB Output is correct
44 Correct 191 ms 17116 KB Output is correct
45 Correct 179 ms 17116 KB Output is correct
46 Correct 188 ms 17244 KB Output is correct
47 Correct 156 ms 15068 KB Output is correct
48 Correct 164 ms 17244 KB Output is correct
49 Correct 527 ms 32980 KB Output is correct
50 Correct 505 ms 32852 KB Output is correct
51 Correct 521 ms 33236 KB Output is correct
52 Correct 508 ms 32728 KB Output is correct
53 Correct 567 ms 32980 KB Output is correct
54 Correct 554 ms 32612 KB Output is correct
55 Correct 1105 ms 61908 KB Output is correct
56 Correct 1129 ms 61856 KB Output is correct
57 Correct 1090 ms 62172 KB Output is correct
58 Correct 1123 ms 62036 KB Output is correct
59 Correct 1106 ms 61992 KB Output is correct
60 Correct 1160 ms 62036 KB Output is correct
61 Correct 1124 ms 61908 KB Output is correct
62 Correct 1132 ms 62000 KB Output is correct