Submission #65507569


Source Code Expand

#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using ti = tuple<int, int, int>;
using tree = tree<int, null_type, less<int>, rb_tree_tag,
                  tree_order_statistics_node_update>;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y,
    Z;
int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int chkd[5101010];
class segtree {
public:
  int size;
  vector<ll> tree;
  segtree(int n) {
    size = 1;
    while (size < n)
      size *= 2;
    tree.assign(2 * size, 1);
    init(1, 1, size);
  }
  void init(int node, int l, int r) {
    if (l == r) {
      tree[node] = 1;
    } else {
      int mid = (l + r) / 2;
      init(node * 2, l, mid);
      init(node * 2 + 1, mid + 1, r);
      tree[node] = tree[node * 2] + tree[node * 2 + 1];
    }
  }
  void update(int pos, ll v) {
    pos += size - 1;
    tree[pos] = v;
    while (pos > 1) {
      pos /= 2;
      tree[pos] = tree[2 * pos] + tree[2 * pos + 1];
    }
  }
  ll kth(int n, int s, int e, int k) {
    if (s == e) {
      return s;
    }
    int mid = (s + e) / 2;
    if (tree[2 * n] >= k) {
      return kth(2 * n, s, mid, k);
    } else {
      return kth(2 * n + 1, mid + 1, e, k - tree[2 * n]);
    }
  }
  ll kth(int k) { return kth(1, 1, size, k); }
};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> T;
  segtree st(3'500'000);
  while (T--) {
    cin >> A >> B;
    if (A <= 3'000'000 && !chkd[A]) {
      // process A
      for (int j = A; j <= 3'000'000; j += A) {
        chkd[j] = 1;
        st.update(j, 0);
      }
    }
    cout << st.kth(B) << '\n';
  }
}

Submission Info

Submission Time
Task C - Removal of Multiples
User RulerOfCakes
Language C++ 20 (gcc 12.2)
Score 600
Code Size 1771 Byte
Status AC
Exec Time 2692 ms
Memory 80556 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 1
AC × 40
Set Name Test Cases
Sample 01_sample_01.txt
All 01_sample_01.txt, 02_small_AB_01.txt, 02_small_AB_02.txt, 02_small_AB_03.txt, 02_small_AB_04.txt, 02_small_AB_05.txt, 03_rand_1_01.txt, 03_rand_1_02.txt, 03_rand_1_03.txt, 03_rand_1_04.txt, 03_rand_1_05.txt, 04_rand_2_01.txt, 04_rand_2_02.txt, 04_rand_2_03.txt, 04_rand_2_04.txt, 04_rand_2_05.txt, 05_rand_3_01.txt, 05_rand_3_02.txt, 05_rand_3_03.txt, 05_rand_3_04.txt, 05_rand_3_05.txt, 06_rand_4_01.txt, 06_rand_4_02.txt, 06_rand_4_03.txt, 06_rand_4_04.txt, 06_rand_4_05.txt, 06_rand_4_06.txt, 06_rand_4_07.txt, 06_rand_4_08.txt, 06_rand_4_09.txt, 06_rand_4_10.txt, 06_rand_4_11.txt, 06_rand_4_12.txt, 06_rand_4_13.txt, 06_rand_4_14.txt, 06_rand_4_15.txt, 06_rand_4_16.txt, 07_max_ans_01.txt, 07_max_ans_02.txt, 07_max_ans_03.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 76 ms 80420 KiB
02_small_AB_01.txt AC 389 ms 80396 KiB
02_small_AB_02.txt AC 405 ms 80348 KiB
02_small_AB_03.txt AC 309 ms 80392 KiB
02_small_AB_04.txt AC 324 ms 80348 KiB
02_small_AB_05.txt AC 335 ms 80340 KiB
03_rand_1_01.txt AC 63 ms 74424 KiB
03_rand_1_02.txt AC 66 ms 80340 KiB
03_rand_1_03.txt AC 62 ms 73208 KiB
03_rand_1_04.txt AC 64 ms 74064 KiB
03_rand_1_05.txt AC 63 ms 76200 KiB
04_rand_2_01.txt AC 229 ms 80312 KiB
04_rand_2_02.txt AC 233 ms 80400 KiB
04_rand_2_03.txt AC 222 ms 80348 KiB
04_rand_2_04.txt AC 221 ms 80516 KiB
04_rand_2_05.txt AC 223 ms 80488 KiB
05_rand_3_01.txt AC 145 ms 80424 KiB
05_rand_3_02.txt AC 164 ms 80492 KiB
05_rand_3_03.txt AC 151 ms 80336 KiB
05_rand_3_04.txt AC 168 ms 80336 KiB
05_rand_3_05.txt AC 149 ms 80396 KiB
06_rand_4_01.txt AC 560 ms 80424 KiB
06_rand_4_02.txt AC 602 ms 80344 KiB
06_rand_4_03.txt AC 585 ms 80412 KiB
06_rand_4_04.txt AC 603 ms 80424 KiB
06_rand_4_05.txt AC 606 ms 80412 KiB
06_rand_4_06.txt AC 605 ms 80376 KiB
06_rand_4_07.txt AC 600 ms 80440 KiB
06_rand_4_08.txt AC 622 ms 80476 KiB
06_rand_4_09.txt AC 523 ms 80492 KiB
06_rand_4_10.txt AC 557 ms 80328 KiB
06_rand_4_11.txt AC 2659 ms 80356 KiB
06_rand_4_12.txt AC 2692 ms 80372 KiB
06_rand_4_13.txt AC 839 ms 80352 KiB
06_rand_4_14.txt AC 869 ms 80348 KiB
06_rand_4_15.txt AC 995 ms 80328 KiB
06_rand_4_16.txt AC 978 ms 80236 KiB
07_max_ans_01.txt AC 590 ms 80344 KiB
07_max_ans_02.txt AC 572 ms 80556 KiB
07_max_ans_03.txt AC 616 ms 80468 KiB