結果
問題 | No.618 labo-index |
ユーザー | pekempey |
提出日時 | 2017-12-18 23:44:58 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 355 ms / 6,000 ms |
コード長 | 996 bytes |
コンパイル時間 | 1,358 ms |
コンパイル使用メモリ | 125,612 KB |
実行使用メモリ | 10,852 KB |
最終ジャッジ日時 | 2023-08-22 06:08:23 |
合計ジャッジ時間 | 8,446 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 4 ms
4,380 KB |
testcase_05 | AC | 5 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 3 ms
4,380 KB |
testcase_09 | AC | 3 ms
4,376 KB |
testcase_10 | AC | 4 ms
4,376 KB |
testcase_11 | AC | 3 ms
4,380 KB |
testcase_12 | AC | 3 ms
4,376 KB |
testcase_13 | AC | 4 ms
4,376 KB |
testcase_14 | AC | 3 ms
4,380 KB |
testcase_15 | AC | 4 ms
4,380 KB |
testcase_16 | AC | 5 ms
4,376 KB |
testcase_17 | AC | 3 ms
4,380 KB |
testcase_18 | AC | 6 ms
4,376 KB |
testcase_19 | AC | 231 ms
4,376 KB |
testcase_20 | AC | 247 ms
4,380 KB |
testcase_21 | AC | 233 ms
4,376 KB |
testcase_22 | AC | 236 ms
4,376 KB |
testcase_23 | AC | 239 ms
4,376 KB |
testcase_24 | AC | 230 ms
4,376 KB |
testcase_25 | AC | 244 ms
4,376 KB |
testcase_26 | AC | 237 ms
4,376 KB |
testcase_27 | AC | 234 ms
4,376 KB |
testcase_28 | AC | 231 ms
4,380 KB |
testcase_29 | AC | 236 ms
4,380 KB |
testcase_30 | AC | 235 ms
4,376 KB |
testcase_31 | AC | 236 ms
4,380 KB |
testcase_32 | AC | 239 ms
4,380 KB |
testcase_33 | AC | 239 ms
4,380 KB |
testcase_34 | AC | 339 ms
10,796 KB |
testcase_35 | AC | 355 ms
10,852 KB |
testcase_36 | AC | 332 ms
6,916 KB |
testcase_37 | AC | 286 ms
7,128 KB |
testcase_38 | AC | 2 ms
4,376 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using Set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { int q; cin >> q; Set<pair<long long, int>> st; vector<pair<long long, int>> tmp; long long u = 0; for (int i = 0; i < q; i++) { int t; long long x; cin >> t >> x; if (t == 1) { int j = tmp.size(); tmp.emplace_back(x - u, j); st.insert(make_pair(x - u, j)); } else if (t == 2) { st.erase(tmp[x - 1]); } else { u += x; } long long ok = 0; long long ng = 2e5; while (ng - ok > 1) { int mid = (ok + ng) / 2; int cnt = st.size() - st.order_of_key(make_pair(mid - u, 0)); if (cnt >= mid) { ok = mid; } else { ng = mid; } } cout << ok << endl; } }