結果
問題 | No.2809 Sort Query |
ユーザー | kwm_t |
提出日時 | 2024-07-13 10:59:47 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,670 bytes |
コンパイル時間 | 6,560 ms |
コンパイル使用メモリ | 322,096 KB |
実行使用メモリ | 33,828 KB |
最終ジャッジ日時 | 2024-07-13 11:00:37 |
合計ジャッジ時間 | 48,383 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 827 ms
32,596 KB |
testcase_02 | AC | 503 ms
32,032 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 484 ms
31,556 KB |
testcase_06 | AC | 361 ms
30,332 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 358 ms
31,808 KB |
testcase_10 | AC | 356 ms
30,684 KB |
testcase_11 | AC | 237 ms
32,684 KB |
testcase_12 | AC | 230 ms
31,704 KB |
testcase_13 | AC | 236 ms
31,700 KB |
testcase_14 | AC | 233 ms
31,592 KB |
testcase_15 | AC | 234 ms
31,460 KB |
testcase_16 | AC | 237 ms
31,316 KB |
testcase_17 | AC | 235 ms
30,876 KB |
testcase_18 | AC | 235 ms
31,536 KB |
testcase_19 | AC | 239 ms
31,176 KB |
testcase_20 | AC | 233 ms
31,380 KB |
testcase_21 | AC | 484 ms
33,680 KB |
testcase_22 | AC | 456 ms
33,516 KB |
testcase_23 | AC | 459 ms
33,568 KB |
testcase_24 | AC | 473 ms
33,452 KB |
testcase_25 | AC | 454 ms
33,496 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 189 ms
31,560 KB |
testcase_37 | AC | 188 ms
31,436 KB |
testcase_38 | AC | 187 ms
31,024 KB |
testcase_39 | AC | 185 ms
32,576 KB |
testcase_40 | AC | 194 ms
32,024 KB |
testcase_41 | AC | 803 ms
27,024 KB |
testcase_42 | AC | 831 ms
26,364 KB |
testcase_43 | AC | 832 ms
26,640 KB |
testcase_44 | AC | 834 ms
26,684 KB |
testcase_45 | AC | 823 ms
25,660 KB |
testcase_46 | AC | 756 ms
25,848 KB |
testcase_47 | AC | 747 ms
26,308 KB |
testcase_48 | AC | 758 ms
25,924 KB |
testcase_49 | AC | 782 ms
25,860 KB |
testcase_50 | AC | 747 ms
25,908 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | AC | 382 ms
29,224 KB |
testcase_62 | AC | 316 ms
19,764 KB |
testcase_63 | WA | - |
testcase_64 | AC | 468 ms
30,332 KB |
testcase_65 | AC | 246 ms
18,492 KB |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 2 ms
6,944 KB |
testcase_69 | WA | - |
testcase_70 | AC | 2 ms
6,944 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 << change[k - 1] << endl; } else { cout << comp[f(k - 1)] << endl; } } } return 0; }