結果

問題 No.628 Tagの勢い
ユーザー newlife171128newlife171128
提出日時 2018-02-15 21:33:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,372 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 175,668 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 20:06:24
合計ジャッジ時間 2,415 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 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 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 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0