結果

問題 No.628 Tagの勢い
ユーザー aaaaaa
提出日時 2018-10-09 14:32:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,820 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 116,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 20:18:35
合計ジャッジ時間 2,237 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 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 5 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 5 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 <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;



int main() {
	int i, j, k;
	int n;
	map<string, int>mp;


	cin >> n;

	for (i = 0; i < n; i++) {
		int num;
		cin >> num;
		int m, s;
		cin >> m >> s;
		for (j = 0; j < m; j++) {
			string str;
			cin >> str;
			if (mp.count(str) == 0) {
				mp.insert(make_pair(str, s));
			}
			else {
				mp[str] += s;
			}

		}

	}

	//map<int, string>mp2;
	vector<pair<int, string>>list;

	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		list.push_back(make_pair(-(*itr).second, (*itr).first));
	}

	//sort(list.begin(), list.end(), greater<pair<int,string>>());
	sort(list.begin(), list.end());

	//map<string, int>::reverse_iterator itr2 = mp.rbegin();
	/*
	while (true) {
		
		bool flag = false;

		for (i = 0; i < list.size() - 1; i++) {
			if (list[i].first == list[i + 1].first) {
				for (j = 0; j < list[i].second.length() || j < list[i + 1].second.length(); j++) {
					if (list[i].second[j] != list[i + 1].second[j]) {
						if ((int)list[i].second[j] > (int)list[i + 1].second[j]) {
							swap(list[i], list[i + 1]);
							flag = true;
							break;
						}
						else {
							break;
						}
					}
				}
				if (flag == true)break;
			}
		}

		if (flag == false) break;
	}
	*/

	if (list.size() <= 10) {
		for (i = 0; i < list.size(); i++) {
			cout << list[i].second << " " << -list[i].first << endl;
		}
	}
	else {
		for (i = 0; i < 10; i++) {
			cout << list[i].second << " " << -list[i].first << endl;
		}
	}





	getchar();
	getchar();
	return 0;
}
0