結果
問題 | No.2809 Sort Query |
ユーザー | kwm_t |
提出日時 | 2024-07-13 11:06:00 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 825 ms / 2,000 ms |
コード長 | 2,676 bytes |
コンパイル時間 | 13,815 ms |
コンパイル使用メモリ | 321,440 KB |
実行使用メモリ | 33,284 KB |
最終ジャッジ日時 | 2024-07-13 11:07:01 |
合計ジャッジ時間 | 51,239 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 510 ms
30,716 KB |
testcase_02 | AC | 491 ms
30,720 KB |
testcase_03 | AC | 502 ms
30,852 KB |
testcase_04 | AC | 507 ms
30,720 KB |
testcase_05 | AC | 481 ms
30,852 KB |
testcase_06 | AC | 359 ms
29,524 KB |
testcase_07 | AC | 343 ms
29,700 KB |
testcase_08 | AC | 368 ms
29,700 KB |
testcase_09 | AC | 358 ms
29,696 KB |
testcase_10 | AC | 354 ms
29,700 KB |
testcase_11 | AC | 232 ms
30,716 KB |
testcase_12 | AC | 224 ms
30,724 KB |
testcase_13 | AC | 232 ms
30,756 KB |
testcase_14 | AC | 232 ms
30,848 KB |
testcase_15 | AC | 234 ms
30,848 KB |
testcase_16 | AC | 255 ms
30,596 KB |
testcase_17 | AC | 235 ms
30,720 KB |
testcase_18 | AC | 232 ms
30,720 KB |
testcase_19 | AC | 236 ms
30,848 KB |
testcase_20 | AC | 231 ms
30,588 KB |
testcase_21 | AC | 448 ms
33,148 KB |
testcase_22 | AC | 477 ms
33,024 KB |
testcase_23 | AC | 452 ms
33,132 KB |
testcase_24 | AC | 459 ms
33,284 KB |
testcase_25 | AC | 454 ms
33,280 KB |
testcase_26 | AC | 641 ms
31,492 KB |
testcase_27 | AC | 636 ms
31,552 KB |
testcase_28 | AC | 629 ms
31,488 KB |
testcase_29 | AC | 630 ms
31,488 KB |
testcase_30 | AC | 625 ms
31,460 KB |
testcase_31 | AC | 363 ms
29,440 KB |
testcase_32 | AC | 363 ms
29,572 KB |
testcase_33 | AC | 356 ms
29,696 KB |
testcase_34 | AC | 374 ms
29,696 KB |
testcase_35 | AC | 355 ms
29,568 KB |
testcase_36 | AC | 187 ms
30,720 KB |
testcase_37 | AC | 186 ms
31,044 KB |
testcase_38 | AC | 187 ms
30,848 KB |
testcase_39 | AC | 208 ms
30,724 KB |
testcase_40 | AC | 187 ms
30,596 KB |
testcase_41 | AC | 820 ms
25,816 KB |
testcase_42 | AC | 816 ms
25,816 KB |
testcase_43 | AC | 807 ms
25,684 KB |
testcase_44 | AC | 825 ms
25,816 KB |
testcase_45 | AC | 788 ms
25,556 KB |
testcase_46 | AC | 780 ms
25,560 KB |
testcase_47 | AC | 772 ms
25,596 KB |
testcase_48 | AC | 736 ms
25,816 KB |
testcase_49 | AC | 780 ms
25,792 KB |
testcase_50 | AC | 791 ms
25,688 KB |
testcase_51 | AC | 577 ms
18,368 KB |
testcase_52 | AC | 581 ms
18,236 KB |
testcase_53 | AC | 610 ms
18,368 KB |
testcase_54 | AC | 573 ms
18,368 KB |
testcase_55 | AC | 616 ms
18,364 KB |
testcase_56 | AC | 388 ms
20,716 KB |
testcase_57 | AC | 326 ms
14,904 KB |
testcase_58 | AC | 324 ms
18,676 KB |
testcase_59 | AC | 339 ms
15,068 KB |
testcase_60 | AC | 292 ms
21,188 KB |
testcase_61 | AC | 408 ms
29,160 KB |
testcase_62 | AC | 317 ms
17,960 KB |
testcase_63 | AC | 401 ms
20,308 KB |
testcase_64 | AC | 483 ms
29,540 KB |
testcase_65 | AC | 244 ms
17,956 KB |
testcase_66 | AC | 2 ms
5,376 KB |
testcase_67 | AC | 2 ms
5,376 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 2 ms
5,376 KB |
testcase_70 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<long long>a(n); rep(i, n)cin >> a[i]; struct Query { int t; int k; long long x; Query(int t = -1, int k = -1, long long x = -1) :t(t), k(k), x(x) {} void output() { std::cout << t << " " << k << " " << x << endl; } }; vector<long long>comp = a; vector<Query>query(q); rep(i, q) { cin >> query[i].t; if (3 == query[i].t) cin >> query[i].k; else if (1 == query[i].t) { cin >> query[i].k >> query[i].x; comp.push_back(query[i].x); } } sort(all(comp)); comp.erase(unique(all(comp)), comp.end()); fenwick_tree<int> bit(comp.size()); rep(i, q) { if (1 == query[i].t) { query[i].x = lower_bound(all(comp), query[i].x) - comp.begin(); } } vector<long long>change(n, -1); vector<pair<long long, long long>>chq; vector<int>upd; rep(i, n) { a[i] = lower_bound(all(comp), a[i]) - comp.begin(); change[i] = a[i]; upd.push_back(i); } bit.add(0, n); auto f = [&](int x)->int { int ok = 0; int ng = comp.size(); while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; bool chk = bit.sum(0, mid) <= x; if (chk)ok = mid; else ng = mid; } return ok; }; rep(i, q) { int t = query[i].t; int k = query[i].k; int x = query[i].x; if (1 == t) { change[k - 1] = x; upd.push_back(k - 1); } else if (2 == t) { while (!upd.empty()) { if (-1 != change[upd.back()]) { int pos = f(upd.back()); chq.push_back({ pos,change[upd.back()] }); change[upd.back()] = -1; } upd.pop_back(); } while (!chq.empty()) { auto[f, s] = chq.back(); bit.add(f, -1); bit.add(s, 1); chq.pop_back(); } } else { if (-1 != change[k - 1]) { cout << comp[change[k - 1]] << endl; } else { cout << comp[f(k - 1)] << endl; } } } return 0; }