結果
| 問題 | No.628 Tagの勢い | 
| コンテスト | |
| ユーザー |  aaa | 
| 提出日時 | 2018-10-09 14:32:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 1,820 bytes | 
| コンパイル時間 | 1,727 ms | 
| コンパイル使用メモリ | 117,108 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-07 22:58:27 | 
| 合計ジャッジ時間 | 2,269 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#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;
}
            
            
            
        