結果
問題 | No.449 ゆきこーだーの雨と雪 (4) |
ユーザー | pekempey |
提出日時 | 2016-11-19 02:24:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 194 ms / 5,000 ms |
コード長 | 2,948 bytes |
コンパイル時間 | 2,184 ms |
コンパイル使用メモリ | 182,616 KB |
実行使用メモリ | 18,916 KB |
最終ジャッジ日時 | 2024-09-22 10:21:51 |
合計ジャッジ時間 | 9,886 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | AC | 3 ms
6,940 KB |
testcase_05 | AC | 3 ms
6,944 KB |
testcase_06 | AC | 3 ms
6,944 KB |
testcase_07 | AC | 3 ms
6,940 KB |
testcase_08 | AC | 3 ms
6,944 KB |
testcase_09 | AC | 3 ms
6,940 KB |
testcase_10 | AC | 3 ms
6,944 KB |
testcase_11 | AC | 3 ms
6,944 KB |
testcase_12 | AC | 163 ms
6,944 KB |
testcase_13 | AC | 164 ms
9,728 KB |
testcase_14 | AC | 183 ms
8,564 KB |
testcase_15 | AC | 152 ms
10,332 KB |
testcase_16 | AC | 170 ms
9,088 KB |
testcase_17 | AC | 177 ms
9,096 KB |
testcase_18 | AC | 162 ms
6,940 KB |
testcase_19 | AC | 186 ms
8,568 KB |
testcase_20 | AC | 188 ms
8,564 KB |
testcase_21 | AC | 160 ms
9,728 KB |
testcase_22 | AC | 164 ms
9,728 KB |
testcase_23 | AC | 162 ms
6,940 KB |
testcase_24 | AC | 174 ms
9,092 KB |
testcase_25 | AC | 178 ms
6,940 KB |
testcase_26 | AC | 188 ms
6,944 KB |
testcase_27 | AC | 165 ms
9,728 KB |
testcase_28 | AC | 171 ms
9,728 KB |
testcase_29 | AC | 185 ms
8,436 KB |
testcase_30 | AC | 154 ms
10,276 KB |
testcase_31 | AC | 166 ms
9,728 KB |
testcase_32 | AC | 190 ms
8,440 KB |
testcase_33 | AC | 181 ms
8,984 KB |
testcase_34 | AC | 181 ms
6,940 KB |
testcase_35 | AC | 151 ms
10,336 KB |
testcase_36 | AC | 188 ms
6,940 KB |
testcase_37 | AC | 156 ms
18,912 KB |
testcase_38 | AC | 194 ms
11,132 KB |
testcase_39 | AC | 178 ms
11,008 KB |
testcase_40 | AC | 183 ms
11,136 KB |
testcase_41 | AC | 134 ms
13,572 KB |
testcase_42 | AC | 136 ms
13,568 KB |
testcase_43 | AC | 170 ms
6,944 KB |
testcase_44 | AC | 129 ms
8,192 KB |
testcase_45 | AC | 157 ms
18,916 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; // left-leaning red-black tree template<class TKey> class Set { public: void insert(TKey key) { root = insert(root, create(key)); root->c = false; } void erase(TKey key) { root = erase(root, key); } int index_of(TKey key) { return index_of(root, key); } private: struct node { node *l; node *r; bool c = 0; int sz = 0; TKey key; bool removed = false; }; node *nil = new node(); node *root = nil; node *create(TKey key) { node *res = new node(); res->l = res->r = nil; res->c = true; res->sz = 1; res->key = key; return res; } node *fix(node *x) { if (x == nil) return x; x->sz = !x->removed + x->l->sz + x->r->sz; return x; } node *rotL(node *x) { node *y = x->r; node *t = y->l; y->l = x; x->r = t; y->c = x->c; x->c = true; fix(x); return fix(y); } node *rotR(node *x) { node *y = x->l; node *t = y->r; y->r = x; x->l = t; y->l->c = false; x->c = false; y->c = true; fix(x); return fix(y); } node *insert(node *x, node *y) { if (x == nil) return y; if (y->key < x->key) { x->l = insert(x->l, y); } else { x->r = insert(x->r, y); } fix(x); if (x->r->c) x = rotL(x); if (x->l->c && x->l->l->c) x = rotR(x); return x; } node *erase(node *x, TKey key) { if (!x->removed && x->key == key) { x->removed = true; return fix(x); } if (key < x->key) { x->l = erase(x->l, key); } else { x->r = erase(x->r, key); } return fix(x); } int index_of(node *x, TKey key) { if (x->key == key) return x->l->sz; if (key < x->key) { return index_of(x->l, key); } else { return x->l->sz + !x->removed + index_of(x->r, key); } } }; int main() { int n, T; cin >> n; vector<int> L(n); for (int i = 0; i < n; i++) scanf("%d", &L[i]); cin >> T; unordered_map<string, pair<int, int>> score; Set<pair<int, int>> st; vector<int> cnt(n); for (int ii = 0; ii < T; ii++) { string name, prob; cin >> name >> prob; int s, t; tie(s, t) = score[name]; if (prob[0] == '?') { printf("%d\n", score.size() - st.index_of(score[name])); } else { int id = prob[0] - 'A'; cnt[id]++; int ss = s + 50 * L[id] + 500 * L[id] / (8 + 2 * cnt[id]); if (s > 0) st.erase({ s, t }); st.insert({ ss, -ii }); score[name] = { ss, -ii }; } } }