結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー startcppstartcpp
提出日時 2016-11-18 23:07:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 2,452 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 82,948 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 18:21:21
合計ジャッジ時間 2,203 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;

int n;
int level[26];
int t;
string name[4000], prob[4000];
vector<string> nameSorted;		//名前 <-> 出席番号の相互変換用 (重複する名前は消去する)。こうすると集計が楽になる。

void input() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> level[i];
	cin >> t;
	for (int i = 0; i < t; i++) cin >> name[i] >> prob[i];
	for (int i = 0; i < t; i++) nameSorted.push_back(name[i]);
	sort(nameSorted.begin(), nameSorted.end());
	nameSorted.erase(unique(nameSorted.begin(), nameSorted.end()), nameSorted.end());	//重複削除
}

//nameSortedを使用
int get_id(string name) {
	return lower_bound(nameSorted.begin(), nameSorted.end(), name) - nameSorted.begin();	//出席番号を返す
}

string get_name(int id) {
	return nameSorted[id];
}

int get_score(char prob, int ac_cnt) {
	int lv = level[prob - 'A'];
	return 50 * lv + 50 * lv / (0.8 + 0.2 * (1 + ac_cnt));
}

//ソート用構造体
struct User {
	int sum_score;
	int last_ac;
	int score[26];
	string name;
	
	void init(int score[], int last_ac, string name) {
		int i;
		
		this->last_ac = last_ac;
		this->name = name;
		
		sum_score = 0;
		for (i = 0; i < n; i++) { this->score[i] = score[i]; sum_score += score[i]; }
	}

	bool operator<(const User &r) const {	//(*this)が先頭側に来る要素ならtrueを返す.
		return (sum_score > r.sum_score) || (sum_score == r.sum_score && last_ac < r.last_ac); 
	}
};

//集計
void syukei() {
	int i;
	int ac_cnt[26] = {0};
	static int score[4000][26];	//score[i][j] = 出席番号iの人がj問目を解いたときのスコア
	int last_ac[4000];			//last_ac[i]  = 出席番号iの人が最後にACした時刻
	
	for (i = 0; i < t; i++) {
		int id = get_id(name[i]);
		int prob_id = prob[i][0] - 'A';
		
		score[id][prob_id] = get_score(prob[i][0], ac_cnt[prob_id]);
		ac_cnt[prob_id]++;
		last_ac[id] = i;
	}
	
	//スコアボードを作成
	vector<User> users;
	users.resize(nameSorted.size());
	
	for (i = 0; i < nameSorted.size(); i++) {
		users[i].init( score[i], last_ac[i], nameSorted[i] );
	}
	sort(users.begin(), users.end());
	
	//表示
	for (i = 0; i < users.size(); i++) {
		cout << i + 1 << " " << users[i].name;
		for (int j = 0; j < n; j++) { cout << " " << users[i].score[j]; }
		cout << " " << users[i].sum_score << endl;
	}
}

int main() {
	input();
	syukei();
	return 0;
}
0