結果

問題 No.628 Tagの勢い
ユーザー ohreitetsuohreitetsu
提出日時 2018-05-14 22:42:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 82,972 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 20:14:38
合計ジャッジ時間 1,777 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct PIC{
	int s;
	string tag;
	PIC(int _s,string _tag){
		s=_s;
		tag=_tag;
	}
};
bool Comp(PIC &l,PIC &r){
	if (l.s>r.s){
		return true;
	}else if (l.s==r.s){
		if (l.tag.compare(r.tag)<0){
			return true;
		}
	}
	return false;
}
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int No;

	vector<PIC> myPIC;
	int i;
	int M,S;
	for (i=0;i<N;i++){
		cin>>No;
		cin>>M>>S;
		for (int j=0;j<M;j++){
			string t;
			cin>>t;
			bool bFound=false;
			for (int k=0;k<myPIC.size();k++){
				if (myPIC[k].tag.compare(t)==0){
					myPIC[k].s+=S;
					bFound=true;
					break;
				}
			}
			if (!bFound){
				myPIC.push_back(PIC(S,t));
			}
		}
	}
	sort(myPIC.begin(),myPIC.end(),Comp);
	for (i=0;i<myPIC.size();i++){
		cout<<myPIC[i].tag<<" "<<myPIC[i].s<<endl;
		if (i==9){
			break;
		}
	}
	return 0;
}
0