結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
newlife171128
|
| 提出日時 | 2018-02-15 21:33:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,372 bytes |
| コンパイル時間 | 2,036 ms |
| コンパイル使用メモリ | 175,816 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-07 22:29:52 |
| 合計ジャッジ時間 | 2,318 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
#include "bits/stdc++.h"
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <unordered_map>
#include <string.h>
#include <utility>
typedef long long ll;
const int INF = 1e8;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef pair<int, int> P;
struct tag_value {
string s;
int v;
};
vector<tag_value> ans;
bool comp(const tag_value& a, const tag_value& b) {
return a.v == b.v ? a.s < b.s : a.v > b.v;
}
map<string, int> web_tast;
int main() {
int n = 0;
cin >> n;
int tag = 0, score = 0;
tag_value tv;
for (int i = 0; i < n; i++) {
cin >> tag;
cin >> tag >> score;
string s;
for (int j = 0; j < tag; j++) {
cin >> s;
web_tast[s] += score;
}
}
map<string, int>::iterator itr;
for (itr = web_tast.begin(); itr != web_tast.end(); ++itr) {
tv.s = itr->first;
tv.v = itr->second;
ans.push_back(tv);
}
sort(ans.begin(), ans.end(), comp);
int ct = ans.size();
if (ct > 10) {
for (int i = 0; i < 10; i++) {
tv = ans[i];
cout << tv.s << " " << tv.v << endl;
}
} else {
for (int i = 0; i < ans.size(); i++) {
tv = ans[i];
cout << tv.s << " " << tv.v << endl;
}
}
return 0;
}
newlife171128