Submission #867405

# Submission time Handle Problem Language Result Execution time Memory
867405 2023-10-28T10:55:26 Z Halym2007 Money (IZhO17_money) C++17
100 / 100
1074 ms 58196 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 5;
#define pb push_back
#define sz size()
#define ff first
#define ss second
int a[N];
int main () {
//	freopen("input.txt", "r", stdin);
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	vector <int> seg;
	set <int> s;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (seg.empty()) {
			seg.pb (a[i]);
			ans++;
		}
		else {
			if (seg.back() > a[i]) {
				for (int i : seg) {
					s.insert (i);
				}
				seg.clear();
				seg.pb (a[i]);
				ans++;
			}
			else if (seg.back() == a[i]) {
				seg.pb (a[i]);
			}
			else {
				// seg[0] bilen a[i] aralyk setda san bamy men shony cek etsem bolyar
				auto tr = s.upper_bound (seg[0]);
				if (tr == s.end()) {
					seg.pb (a[i]);
				}	
				else {
					if (*tr < a[i]) {
						for (int i : seg) {
						s.insert (i);
						}
						seg.clear();
						ans++;
						seg.pb (a[i]);
					}
					else seg.pb (a[i]);
				}
			}
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 756 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 756 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 416 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 756 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 416 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 504 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 756 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 416 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 504 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 120 ms 5712 KB Output is correct
40 Correct 202 ms 8584 KB Output is correct
41 Correct 87 ms 5200 KB Output is correct
42 Correct 81 ms 4820 KB Output is correct
43 Correct 65 ms 4164 KB Output is correct
44 Correct 234 ms 10836 KB Output is correct
45 Correct 232 ms 10824 KB Output is correct
46 Correct 242 ms 11216 KB Output is correct
47 Correct 226 ms 11076 KB Output is correct
48 Correct 225 ms 11064 KB Output is correct
49 Correct 433 ms 29532 KB Output is correct
50 Correct 408 ms 29456 KB Output is correct
51 Correct 410 ms 29504 KB Output is correct
52 Correct 410 ms 29524 KB Output is correct
53 Correct 383 ms 29464 KB Output is correct
54 Correct 421 ms 29448 KB Output is correct
55 Correct 874 ms 58196 KB Output is correct
56 Correct 861 ms 58040 KB Output is correct
57 Correct 926 ms 58048 KB Output is correct
58 Correct 937 ms 57972 KB Output is correct
59 Correct 908 ms 57920 KB Output is correct
60 Correct 1012 ms 57804 KB Output is correct
61 Correct 1045 ms 57912 KB Output is correct
62 Correct 1074 ms 58040 KB Output is correct