結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー HO_RI1991HO_RI1991
提出日時 2016-11-21 12:18:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 2,210 bytes
コンパイル時間 1,466 ms
コンパイル使用メモリ 126,736 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 06:08:45
合計ジャッジ時間 3,054 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<stack>
#include<set>
#include<sstream>
#include<fstream>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

struct Score{
	long long score;
	int last_ans;
	vector<int> scores;
	Score(int last,int N):last_ans(last),score(0),scores(N,0){}
};

int get_score(int star,int order){
	return 50*star+(double)((50.*(double)(star))/(0.8+0.2*(double)(order)));
}

int main(){
//	ifstream fin("gen_case_1.txt");

	int N;
	cin>>N;
	vector<int> L(N);
	for(auto& val:L)
		cin>>val;

	int T;
	cin>>T;
	vector<pair<string,int>> List(T);
	unordered_map<string,Score> LastAns;
	for(int i=0;i<T;++i){
		char str;
		cin>>List[i].first>>str;
		List[i].second=str-'A';
		auto itr=LastAns.find(List[i].first);
		if(itr!=end(LastAns)){
			itr->second.last_ans=i;
		}
		else{
			LastAns.insert(make_pair(List[i].first,Score(i,N)));
		}
	}
	vector<int> Num(N,0);
	for(const auto& answer:List){
		auto itr=LastAns.find(answer.first);
		itr->second.score+=get_score(L[answer.second],++Num[answer.second]);
		itr->second.scores[answer.second]=get_score(L[answer.second],Num[answer.second]);
	}

	vector<pair<string,long long>> Scores(LastAns.size());
	auto itr=LastAns.begin();
	for(int i=0;i<LastAns.size();++i){
		Scores[i].first=itr->first;
		Scores[i].second=itr->second.score;
		++itr;
	}

	sort(begin(Scores),end(Scores),[&](auto x,auto y){
		if(x.second==y.second){
			auto x_itr=LastAns.find(x.first);
			auto y_itr=LastAns.find(y.first);
			return x_itr->second.last_ans<y_itr->second.last_ans;
		}
		else{
			return x.second>y.second;
		}
	});

	//ofstream fout("out.txt");

	for(int i=0;i<Scores.size();++i){
		cout<<i+1<<" "<<Scores[i].first;
		auto itr=LastAns.find(Scores[i].first);
		for(const auto& val:itr->second.scores){
			cout<<" "<<val;
		}
		cout<<" "<<Scores[i].second<<endl;
	}
	return 0;
}
0