結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー masamasa
提出日時 2016-11-19 00:25:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,638 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 99,364 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-17 13:16:03
合計ジャッジ時間 2,922 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 15 ms
4,500 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 16 ms
4,384 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 14 ms
4,380 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 19 ms
4,380 KB
testcase_20 AC 16 ms
4,376 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 12 ms
4,380 KB
testcase_25 AC 16 ms
4,380 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

using namespace std;

typedef map<string, vector<int>> MSV;
typedef pair<string, vector<int>> PSV;

int f(int n, int k) {
	int ret = 50 * n + int(500.0 * n / (8 + 2 * k));
	return ret;
}

int main() {
	int n, t;
	cin >> n;

	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	cin >> t;
	string user;
	char problem_code;

	vector<int> n_ac(n, 0);
	MSV users;

	int idx_sum = n;
	int idx_last_timing = n + 1;

	for (int i = 0; i < t; i++) {
		cin >> user >> problem_code;
		int problem = problem_code - 'A';
		n_ac[problem]++;

		int point = f(l[problem], n_ac[problem]);

		auto it = users.find(user);
		if (it == users.end()) {
			vector<int> v(n + 2, 0);
			v[problem] = point;
			v[idx_sum] += point;
			v[idx_last_timing] = i;

			users[user] = v;
		} else {
			it->second[problem] = point;
			it->second[idx_sum] += point;
			it->second[idx_last_timing] = i;
		}
	}

	vector<PSV> user_vec;
	for (auto p : users) {
		user_vec.emplace_back(make_pair(p.first, p.second));
	}


	sort(user_vec.begin(), user_vec.end(),
		 [&idx_sum, &idx_last_timing](PSV &p1, PSV&p2) {
		 	if (p1.second[idx_sum] == p2.second[idx_sum]) {
		 		return p1.second[idx_last_timing] < p2.second[idx_last_timing];
		 	} else {
		 		return p1.second[idx_sum] > p2.second[idx_sum];
		 	}
		 	return true;
		 }
	);

	for (int i = 0; i < user_vec.size(); i++) {
		cout << i + 1 << " " << user_vec[i].first;
		for (int j = 0; j <= n; j++) {
			cout << " " << user_vec[i].second[j];
		}
		cout << endl;
	}

	return 0;
}
0