結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー antaanta
提出日時 2016-11-18 06:22:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,400 ms / 5,000 ms
コード長 1,321 bytes
コンパイル時間 1,899 ms
コンパイル使用メモリ 180,736 KB
実行使用メモリ 14,744 KB
最終ジャッジ日時 2023-10-22 08:28:11
合計ジャッジ時間 14,651 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 107 ms
4,348 KB
testcase_13 AC 486 ms
6,796 KB
testcase_14 AC 237 ms
6,784 KB
testcase_15 AC 606 ms
6,788 KB
testcase_16 AC 361 ms
6,780 KB
testcase_17 AC 363 ms
6,792 KB
testcase_18 AC 107 ms
4,348 KB
testcase_19 AC 235 ms
6,784 KB
testcase_20 AC 234 ms
6,772 KB
testcase_21 AC 479 ms
6,784 KB
testcase_22 AC 488 ms
6,796 KB
testcase_23 AC 107 ms
4,348 KB
testcase_24 AC 360 ms
6,780 KB
testcase_25 AC 90 ms
4,348 KB
testcase_26 AC 72 ms
4,348 KB
testcase_27 AC 484 ms
6,788 KB
testcase_28 AC 479 ms
6,792 KB
testcase_29 AC 232 ms
6,772 KB
testcase_30 AC 603 ms
6,788 KB
testcase_31 AC 489 ms
6,796 KB
testcase_32 AC 227 ms
6,780 KB
testcase_33 AC 348 ms
6,788 KB
testcase_34 AC 92 ms
4,348 KB
testcase_35 AC 606 ms
6,788 KB
testcase_36 AC 90 ms
4,348 KB
testcase_37 AC 112 ms
14,744 KB
testcase_38 AC 93 ms
9,276 KB
testcase_39 AC 71 ms
9,276 KB
testcase_40 AC 71 ms
9,276 KB
testcase_41 AC 899 ms
9,276 KB
testcase_42 AC 1,400 ms
9,276 KB
testcase_43 AC 65 ms
4,348 KB
testcase_44 AC 105 ms
4,348 KB
testcase_45 AC 63 ms
14,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0