Submission #1067251

# Submission time Handle Problem Language Result Execution time Memory
1067251 2024-08-20T13:28:38 Z juicy Employment (JOI16_employment) C++17
100 / 100
524 ms 25500 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

template<class T>
using Tree = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  int n, m; cin >> n >> m;
  vector<int> a(n);
  array<Tree<int>, 2> st;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    st[0].insert(a[i]);
    if (i) {
      st[1].insert(min(a[i], a[i - 1]));
    }
  }
  auto ers = [&](int i) {
    st[0].erase(st[0].upper_bound(a[i]));
    if (i) {
      st[1].erase(st[1].upper_bound(min(a[i], a[i - 1])));
    }
    if (i + 1 < n) {
      st[1].erase(st[1].upper_bound(min(a[i], a[i + 1])));
    }
  };
  auto ins = [&](int i, int x) {
    a[i] = x;
    st[0].insert(a[i]);
    if (i) {
      st[1].insert(min(a[i], a[i - 1]));
    }
    if (i + 1 < n) {
      st[1].insert(min(a[i], a[i + 1]));
    }
  };
  auto count = [&](Tree<int> &st, int x) {
    return st.size() - st.order_of_key(x);
  };
  auto qry = [&](int x) {
    return count(st[0], x) - count(st[1], x);
  };
  while (m--) {
    int t; cin >> t;
    if (t == 1) {
      int b; cin >> b;
      cout << qry(b) << "\n";
    } else {
      int c, d; cin >> c >> d; --c;
      ers(c);
      ins(c, d);
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 16 ms 1956 KB Output is correct
5 Correct 39 ms 4700 KB Output is correct
6 Correct 52 ms 5456 KB Output is correct
7 Correct 92 ms 10020 KB Output is correct
8 Correct 118 ms 11572 KB Output is correct
9 Correct 213 ms 16068 KB Output is correct
10 Correct 246 ms 22356 KB Output is correct
11 Correct 257 ms 21588 KB Output is correct
12 Correct 307 ms 24656 KB Output is correct
13 Correct 330 ms 25172 KB Output is correct
14 Correct 296 ms 24396 KB Output is correct
15 Correct 333 ms 24660 KB Output is correct
16 Correct 310 ms 25432 KB Output is correct
17 Correct 347 ms 25464 KB Output is correct
18 Correct 302 ms 25424 KB Output is correct
19 Correct 318 ms 25464 KB Output is correct
20 Correct 308 ms 25500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 16 ms 1956 KB Output is correct
20 Correct 39 ms 4700 KB Output is correct
21 Correct 52 ms 5456 KB Output is correct
22 Correct 92 ms 10020 KB Output is correct
23 Correct 118 ms 11572 KB Output is correct
24 Correct 213 ms 16068 KB Output is correct
25 Correct 246 ms 22356 KB Output is correct
26 Correct 257 ms 21588 KB Output is correct
27 Correct 307 ms 24656 KB Output is correct
28 Correct 330 ms 25172 KB Output is correct
29 Correct 296 ms 24396 KB Output is correct
30 Correct 333 ms 24660 KB Output is correct
31 Correct 310 ms 25432 KB Output is correct
32 Correct 347 ms 25464 KB Output is correct
33 Correct 302 ms 25424 KB Output is correct
34 Correct 318 ms 25464 KB Output is correct
35 Correct 308 ms 25500 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 2 ms 600 KB Output is correct
38 Correct 3 ms 604 KB Output is correct
39 Correct 29 ms 2692 KB Output is correct
40 Correct 47 ms 3412 KB Output is correct
41 Correct 86 ms 5456 KB Output is correct
42 Correct 127 ms 9040 KB Output is correct
43 Correct 183 ms 11344 KB Output is correct
44 Correct 405 ms 23084 KB Output is correct
45 Correct 300 ms 18260 KB Output is correct
46 Correct 351 ms 20048 KB Output is correct
47 Correct 511 ms 25172 KB Output is correct
48 Correct 473 ms 24828 KB Output is correct
49 Correct 491 ms 25200 KB Output is correct
50 Correct 474 ms 24912 KB Output is correct
51 Correct 524 ms 25456 KB Output is correct
52 Correct 484 ms 25484 KB Output is correct
53 Correct 488 ms 25428 KB Output is correct
54 Correct 513 ms 25380 KB Output is correct
55 Correct 524 ms 25428 KB Output is correct