結果
| 問題 | No.628 Tagの勢い | 
| コンテスト | |
| ユーザー |  uafr_cs | 
| 提出日時 | 2018-01-05 21:31:28 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 295 ms / 2,000 ms | 
| コード長 | 1,467 bytes | 
| コンパイル時間 | 2,358 ms | 
| コンパイル使用メモリ | 88,724 KB | 
| 実行使用メモリ | 48,420 KB | 
| 最終ジャッジ日時 | 2024-10-07 22:06:18 | 
| 合計ジャッジ時間 | 6,950 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
	
	public static class Pair implements Comparable<Pair> {
		String tag;
		long score;
		
		public Pair(String tag, long score){
			this.tag = tag;
			this.score = score;
		}
		@Override
		public int compareTo(Pair o) {
			if(Long.compare(o.score, this.score) != 0){
				return Long.compare(o.score, this.score);
			}else{
				return this.tag.compareTo(o.tag);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		HashMap<String, Long> dict = new HashMap<String, Long>();
		
		for(int i = 0; i < N; i++){
			final int id = sc.nextInt();
			final int M = sc.nextInt();
			final int S = sc.nextInt();
			
			for(int j = 0; j < M; j++){
				final String tag = sc.next();
				if(!dict.containsKey(tag)){
					dict.put(tag, 0l);
				}
				dict.put(tag, dict.get(tag) + S);
			}
		}
		
		PriorityQueue<Pair> queue = new PriorityQueue<Pair>();
		for(final Entry<String, Long> entry : dict.entrySet()){
			queue.add(new Pair(entry.getKey(), entry.getValue()));
		}
		
		for(int i = 0; i < 10 && !queue.isEmpty(); i++){
			final Pair pair = queue.poll();
			
			System.out.println(pair.tag + " " + pair.score);
		}
		
		
	}
}
            
            
            
        