結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー ohreitetsuohreitetsu
提出日時 2018-06-17 23:05:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,824 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 90,456 KB
実行使用メモリ 4,896 KB
最終ジャッジ日時 2023-09-13 06:31:25
合計ジャッジ時間 3,692 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int N;
vector<int> L;
struct GRADE{
	char P;
	int Order;
	int Grade;
	GRADE(char p){
		P=p;
		Order=0;
		Grade=0;
	}
	void SetGrade(int order){
		Order=order;
		Grade=(int)(50*L[P-'A']+50*L[P-'A']/(0.8+0.2*Order));
	}
};
struct PERSON{
	int Index;
	string Name;
	vector<GRADE> Grade;
	PERSON(int index,string name,char p,int gradeNum,int order){
		Index=index;
		Name=name;
		for (int i=0;i<gradeNum;i++){
			Grade.push_back(GRADE(i+'A'));
		}
		Grade[p-'A'].SetGrade(order);
	}
	void SetGrade(int index,char p,int order){
		Index=index;
		Grade[p-'A'].SetGrade(order);
	}
	void Print(){
		cout<<Name<<" ";
		int Sum=0;
		for (int i=0;i<Grade.size();i++){
			Sum+=Grade[i].Grade;
			cout<<Grade[i].Grade;
			cout<<" ";
		}
		cout<<Sum<<endl;
	}
};
bool Comp2(PERSON &l,PERSON &r){
	int Sum1=0,Sum2=0;
	int i;
	for (i=0;i<l.Grade.size();i++){
		Sum1+=l.Grade[i].Grade;
	}
	for (i=0;i<r.Grade.size();i++){
		Sum2+=r.Grade[i].Grade;
	}
	if (Sum1>Sum2){
		return true;
	}else if (Sum1==Sum2){
		if (l.Index<r.Index){
			return true;
		}
	}
	return false;
}
int main(int argc, char* argv[])
{

	cin>>N;

	int i,j;
	int l;
	for (i=0;i<N;i++){
		cin>>l;
		L.push_back(l);
	}
	int T;
	cin>>T;
	vector<string> Name(T);
	vector<char> P(T);
	vector<int> order(N);
	string name;
	char p;
	vector<PERSON> Person; 
	for (i=0;i<T;i++){
		cin>>name>>p;
		order[p-'A']++;
		int J=-1;
		for (j=0;j<Person.size();j++){
			if (!Person[j].Name.compare(name)){
				J=j;
				break;
			}
		}
		if (J==-1){
			Person.push_back(PERSON(i+1,name,p,N,order[p-'A']));
		}else{
			Person[J].SetGrade(i+1,p,order[p-'A']);
		}
	}
	sort(Person.begin(),Person.end(),Comp2);
	for (i=0;i<Person.size();i++){
		cout<<i+1<<" ";
		Person[i].Print();
	}

	return 0;
}
0