Submission #533234

# Submission time Handle Problem Language Result Execution time Memory
533234 2022-03-05T07:20:11 Z devariaota Money (IZhO17_money) C++17
45 / 100
1500 ms 11480 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n;
int lst[1000005];
vector<int> arr;
map <int, bool> mp; 

int binser(int x) {
  int l = 0, r = arr.size(), ans = -1;
  r--;
  while(l <= r) {
    int mid = (l + r) / 2;
    if (arr[mid] <= x) {
      ans = mid;
      l = mid + 1;
    }
    else {
      r = mid - 1;
    }
  }
  return ans;
}

int main() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> lst[i];
  }
  
  int l = 1;
  int ans = 0;
  while(l <= n) {
    //cout << "::" << l << endl;
    ans++;
    int loc = binser(lst[l]);
    int r = l + 1;
    while(r <= n && lst[r] >= lst[r - 1]) {
      int loc1 = binser(lst[r]);
      
      //cout << r << " " << loc << " " << loc1 << endl;
      if (loc1 >= 0 && lst[r] == arr[loc1] && loc == loc1 - 1) {
        loc1--;
      }
      if (loc == loc1) {
        r++;
      }
      else {
        break;
      }
    }
    for(int i = l; i < r; i++) {
      if (mp.count(lst[i])) {
        continue;
      }
      mp.insert({lst[i], true});
      arr.push_back(lst[i]);
    }
    sort(arr.begin(), arr.end());
    l = r;
  }
  cout << ans;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 300 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 304 KB Output is correct
31 Correct 1 ms 268 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 2 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 300 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 304 KB Output is correct
31 Correct 1 ms 268 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 2 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 150 ms 5384 KB Output is correct
40 Correct 283 ms 8668 KB Output is correct
41 Correct 132 ms 4420 KB Output is correct
42 Correct 127 ms 3864 KB Output is correct
43 Correct 86 ms 2884 KB Output is correct
44 Correct 364 ms 10872 KB Output is correct
45 Correct 327 ms 10820 KB Output is correct
46 Correct 417 ms 10976 KB Output is correct
47 Correct 306 ms 11088 KB Output is correct
48 Correct 336 ms 11036 KB Output is correct
49 Execution timed out 1577 ms 11480 KB Time limit exceeded
50 Halted 0 ms 0 KB -