結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー kimiyuki
提出日時 2016-11-24 23:22:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,466 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 113,148 KB
実行使用メモリ 25,148 KB
最終ジャッジ日時 2024-09-22 10:28:26
合計ジャッジ時間 10,245 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); }
template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector
    <decltype(cont)>(x, cont); }
template <typename T> T sortunique(T xs) { whole(sort, xs); xs.erase(whole(unique, xs), xs.end()); return xs; }
template <typename T> int index(vector<T> const & xs, T x) { return whole(lower_bound, xs, x) - xs.begin(); }
template <typename T>
struct binary_indexed_tree { // on monoid
vector<T> data;
T unit;
function<T (T,T)> append; // associative
template <typename F>
binary_indexed_tree(size_t n, T a_unit, F a_append) : data(n, a_unit), unit(a_unit), append(a_append) {}
void point_append(size_t i, T w) { // data[i] += w
for (size_t j = i+1; j <= data.size(); j += j & -j) data[j-1] = append(data[j-1], w);
}
int initial_range_concat(size_t i) { // sum [0, i)
T acc = unit;
for (size_t j = i; 0 < j; j -= j & -j) acc = append(acc, data[j-1]);
return acc;
}
};
double scoreof(int level, int solved) {
assert (solved >= 1);
return 50*level + 250*level/(4.0+solved);
}
int main() {
// input
int n; cin >> n;
vector<int> level(n);
repeat (i,n) cin >> level[i];
int query; cin >> query;
vector<string> name(query);
vector<char> action(query);
repeat (t,query) cin >> name[t] >> action[t];
// prepare
vector<string> sorted_names = sortunique(name);
int m = sorted_names.size();
vector<int> id(query);
vector<double> sorted_scores; {
vector<double> found_scores(query + 1);
vector<double> score(m);
vector<int> solved(n);
repeat (t,query) {
id[t] = index(sorted_names, name[t]);
if (action[t] != '?') {
int i = action[t] - 'A';
solved[i] += 1;
score[id[t]] += scoreof(level[i], solved[i]);
found_scores[t] = score[id[t]];
}
}
sorted_scores = sortunique(found_scores);
}
// answer
vector<int> solved(n);
vector<double> score(m);
binary_indexed_tree<int> bit(sorted_scores.size(), int(), plus<int>());
bit.point_append(0, m);
vector<vector<int> > tiebreak(sorted_scores.size());
repeat (t,query) {
int j = index(sorted_scores, score[id[t]]);
if (action[t] == '?') {
int a = bit.initial_range_concat(j);
int b = tiebreak[j].size() - (whole(find, tiebreak[j], id[t]) - tiebreak[j].begin()) - 1;
cout << m-a-b << endl;
} else {
bit.point_append(j, -1);
if (j) tiebreak[j].erase(whole(find, tiebreak[j], id[t]));
int i = action[t] - 'A';
solved[i] += 1;
score[id[t]] += scoreof(level[i], solved[i]);
j = index(sorted_scores, score[id[t]]);
bit.point_append(j, +1);
tiebreak[j].push_back(id[t]);
}
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0