結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-08-19 12:20:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 1,211 bytes |
| コンパイル時間 | 1,446 ms |
| コンパイル使用メモリ | 116,104 KB |
| 最終ジャッジ日時 | 2025-02-16 11:29:02 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘bool comp(std::pair<int, std::__cxx11::basic_string<char> >&, std::pair<int, std::__cxx11::basic_string<char> >&)’:
main.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
18 | }
| ^
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
#include<vector>
#include <utility>
using namespace std;
bool comp(pair<int, string> &a, pair<int, string> &b){
if (a.first != b.first) return a.first > b.first;
else if (a.second != b.second) return a.second < b.second;
}
int main()
{
int n, num;
cin >> n;
vector<pair<int, string>> vec;
for (int i = 0; i < n; i++){
int m, s;
cin >> num >> m >>s;
for (int j = 0; j < m; j++){
string tag;
cin >> tag;
int vs = vec.size();
for (int k = 0; k < vs; k++){
if (vec.at(k).second == tag){
vec.at(k).first += s;
break;
}
if (k == vec.size() - 1) vec.push_back(make_pair(s, tag));
}
if (vec.size() == 0) vec.push_back(make_pair(s, tag));
}
}
sort(vec.begin(), vec.end(), comp);
num = 0;
for (auto x : vec){
cout << x.second << " " << x.first << endl;
num++;
if (num == 10) break;
}
}
kpinkcat