結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2016-06-23 19:00:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 780 bytes |
| コンパイル時間 | 1,006 ms |
| コンパイル使用メモリ | 83,576 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 22:00:08 |
| 合計ジャッジ時間 | 1,956 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#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;
}
}
horiesiniti