結果

問題 No.628 Tagの勢い
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-06-23 19:00:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 83,220 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 19:54:38
合計ジャッジ時間 1,715 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 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 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |                 scanf("%d",&no);
      |                 ~~~~~^~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf("%d %d",&m,&s);
      |                 ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<map>
#include<iostream>
#include<algorithm>
#include<vector>

struct E{
	int score;
	std::string tag;
	bool operator<(const E& e)const{
		if(score!=e.score)return score>e.score;
		return tag<e.tag;
	}
};

int main(){
	int n;
	scanf("%d",&n);
	std::map<std::string,int> sum;
	std::string str;
	for(int i=0;i<n;i++){
		int no;
		scanf("%d",&no);
		int m,s;
		scanf("%d %d",&m,&s);
		for(int j=0;j<m;j++){
			std::cin>>str;
			sum[str]+=s;
		}
	}
	E e;
	std::vector<E> vec;
	std::map<std::string,int>::iterator it;
	for(it=sum.begin();it!=sum.end();it++){
		e.score=(*it).second;
		e.tag=(*it).first;
		vec.push_back(e);
	}
	std::sort(vec.begin(),vec.end());
	for(int i=0;i<10&&i<vec.size();i++){
		std::cout<<vec[i].tag<<" "<<vec[i].score<<std::endl;
	}
}
0