Submission #533263

# Submission time Handle Problem Language Result Execution time Memory
533263 2022-03-05T08:11:23 Z christinelynn Money (IZhO17_money) C++17
100 / 100
1112 ms 51488 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n;
int arr[1000005];
set<int> st;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  
  int l = 1;
  int ans = 0;
  while(l <= n) {
    //cout << "::" << l << endl;
    ans++;
    auto loc = st.lower_bound(arr[l]);
    auto opt = st.upper_bound(arr[l]);
    int r = l + 1;
    while(r <= n && arr[r] >= arr[r - 1]) {
      auto loc1 = st.lower_bound(arr[r]);
      
      //cout << r << " " << loc << " " << loc1 << endl;
      //cout << *loc << " " << *opt << " " << *loc1 << endl;
      if (*loc == *loc1 || *opt == *loc1) {
        r++;
      }
      else {
        break;
      }
    }
    for(int i = l; i < r; i++) {
      st.insert(arr[i]);
    }
    l = r;
  }
  cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 324 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 324 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 48 ms 2456 KB Output is correct
40 Correct 91 ms 3684 KB Output is correct
41 Correct 39 ms 1968 KB Output is correct
42 Correct 39 ms 1708 KB Output is correct
43 Correct 33 ms 1348 KB Output is correct
44 Correct 113 ms 4524 KB Output is correct
45 Correct 109 ms 4620 KB Output is correct
46 Correct 111 ms 4520 KB Output is correct
47 Correct 90 ms 4496 KB Output is correct
48 Correct 92 ms 4548 KB Output is correct
49 Correct 458 ms 23060 KB Output is correct
50 Correct 541 ms 22912 KB Output is correct
51 Correct 497 ms 22852 KB Output is correct
52 Correct 483 ms 22904 KB Output is correct
53 Correct 497 ms 22900 KB Output is correct
54 Correct 466 ms 22888 KB Output is correct
55 Correct 1066 ms 51480 KB Output is correct
56 Correct 1082 ms 51428 KB Output is correct
57 Correct 1064 ms 51448 KB Output is correct
58 Correct 1084 ms 51432 KB Output is correct
59 Correct 1074 ms 51464 KB Output is correct
60 Correct 1046 ms 51376 KB Output is correct
61 Correct 1084 ms 51384 KB Output is correct
62 Correct 1112 ms 51488 KB Output is correct