Submission #710140

# Submission time Handle Problem Language Result Execution time Memory
710140 2023-03-15T05:05:28 Z arcane Money (IZhO17_money) C++17
100 / 100
1188 ms 63016 KB
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
const int MAX_A = 1e6 + 5;
int cnt[MAX_A];
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int ans = 0, n, x, prevx = -1; cin >> n;
	int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i];
	set <int> s;
	bool flag = false;
	for (int i = 0; i < n; i++){
		x = arr[i];
		s.insert(arr[i]);
		cnt[arr[i]]++;
		if (!i){
			ans += 1;
			flag = true;
		}
		else if (flag){
			if (prevx > x){
				ans += 1;
				flag = true;
			} 
			else if (prevx < x){
				auto it = s.find(prevx);
				it++;
				if (it != s.end() and x <= *it){
					flag = false;
				}
				else ans += 1, flag = true;
			}
		}
		else{
			if (prevx > x){
				ans += 1;
				flag = true;
			}
			else if (prevx < x){
				auto it = s.find(prevx);
				it++;
				if (it != s.end() and x <= *it and cnt[prevx] == 1){
					//cerr << prevx << ' ' << *it << ' ' << x << '\n';
					flag = false;
				}
				else ans += 1, flag = true;
			}
		}
		//cerr << ans << '\n';
		//cerr << ans << ' ' << *prev << ' ' << *cur << '\n';
		prevx = x;
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 1 ms 852 KB Output is correct
39 Correct 63 ms 4092 KB Output is correct
40 Correct 97 ms 6540 KB Output is correct
41 Correct 66 ms 3468 KB Output is correct
42 Correct 103 ms 3000 KB Output is correct
43 Correct 29 ms 2224 KB Output is correct
44 Correct 114 ms 8132 KB Output is correct
45 Correct 102 ms 8148 KB Output is correct
46 Correct 112 ms 8176 KB Output is correct
47 Correct 89 ms 8148 KB Output is correct
48 Correct 98 ms 8148 KB Output is correct
49 Correct 538 ms 34428 KB Output is correct
50 Correct 544 ms 34508 KB Output is correct
51 Correct 502 ms 34400 KB Output is correct
52 Correct 430 ms 34432 KB Output is correct
53 Correct 539 ms 34336 KB Output is correct
54 Correct 520 ms 34380 KB Output is correct
55 Correct 1188 ms 62920 KB Output is correct
56 Correct 1034 ms 63016 KB Output is correct
57 Correct 951 ms 62796 KB Output is correct
58 Correct 997 ms 62984 KB Output is correct
59 Correct 960 ms 63012 KB Output is correct
60 Correct 1020 ms 62956 KB Output is correct
61 Correct 935 ms 62800 KB Output is correct
62 Correct 967 ms 63004 KB Output is correct