結果
| 問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
| ユーザー |
anta
|
| 提出日時 | 2016-11-18 06:22:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,376 ms / 5,000 ms |
| コード長 | 1,321 bytes |
| コンパイル時間 | 1,788 ms |
| コンパイル使用メモリ | 180,392 KB |
| 実行使用メモリ | 14,800 KB |
| 最終ジャッジ日時 | 2024-09-22 09:27:06 |
| 合計ジャッジ時間 | 14,760 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
//Ω(人)かける最大限の手抜きバージョン
int main() {
int N;
scanf("%d", &N);
vector<int> L(N);
for(int i = 0; i < N; ++ i)
scanf("%d", &L[i]);
int T;
scanf("%d", &T);
const int MaxScore = 15600;
struct Contestant {
int totalScore;
int lastTime;
Contestant() : totalScore(0), lastTime(0) {}
unsigned calc(int T) const {
return (unsigned)(MaxScore - totalScore) * T + lastTime;
}
};
std::map<std::string, Contestant> contestants;
std::vector<int> count(N, 0);
assert((long long)(MaxScore + 1) * T <= 1LL << 32);
vector<unsigned> list;
for(int i = 0; i < T; ++ i) {
char name[17], P[2];
scanf("%s%s", name, P);
if(*P != '?') {
int p = *P - 'A';
int stars = L[p];
int rank = ++ count[p];
int score = 50 * stars + 50 * stars * 10 / (8 + 2 * rank);
auto &c = contestants[name];
if(c.totalScore != 0)
list.erase(find(list.begin(), list.end(), c.calc(T)));
c.totalScore += score;
c.lastTime = i + 1;
assert(c.totalScore <= MaxScore);
list.insert(lower_bound(list.begin(), list.end(), c.calc(T)), c.calc(T));
} else {
auto &c = contestants[name];
int ans = (int)(lower_bound(list.begin(), list.end(), c.calc(T)) - list.begin());
printf("%d\n", ans + 1);
}
}
return 0;
}
anta