結果

問題 No.628 Tagの勢い
ユーザー YamaKasaYamaKasa
提出日時 2018-03-31 03:22:06
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,117 bytes
コンパイル時間 3,704 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 48,860 KB
最終ジャッジ日時 2024-04-16 20:11:53
合計ジャッジ時間 8,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 170 ms
42,712 KB
testcase_02 RE -
testcase_03 AC 172 ms
42,624 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 172 ms
42,804 KB
testcase_07 AC 170 ms
42,544 KB
testcase_08 AC 179 ms
42,608 KB
testcase_09 AC 179 ms
42,720 KB
testcase_10 AC 200 ms
42,628 KB
testcase_11 AC 180 ms
41,920 KB
testcase_12 AC 296 ms
48,860 KB
testcase_13 AC 298 ms
48,420 KB
testcase_14 AC 295 ms
48,176 KB
testcase_15 AC 299 ms
48,756 KB
testcase_16 AC 275 ms
48,492 KB
testcase_17 RE -
testcase_18 AC 165 ms
42,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

public class Tag {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int []No = new int[N];
		int []S = new int[N];

		//String str[][] = new String[N][];
		HashMap<Integer, HashMap<Integer, String>> strD2
				= new HashMap<Integer, HashMap<Integer, String>>();
		for(int i = 0; i < N; i++) {
			No[i] =  scanner.nextInt();
			int M = scanner.nextInt();
			S[i] = scanner.nextInt();
			HashMap<Integer, String> strD1 = new HashMap<Integer, String>();
			for(int j = 0; j < M; j++) {
				String s = scanner.next();
				strD1.put(j, s);

			}
			strD2.put(i, strD1);
		}
		scanner.close();


		HashMap<String, Integer> pointHM = new HashMap<String,Integer>();
		pointHM.put(strD2.get(0).get(0), 0);
		int k;
		String key;
		for(int i = 0; i < N; i++) {
			k = strD2.get(i).size();
			for(int j = 0; j < k; j++) {
				key = strD2.get(i).get(j);
				if(pointHM.containsKey(key)) {
					int s = pointHM.get(key);
					pointHM.put(key, s + S[i]);
				}else {
					pointHM.put(key, S[i]);
				}
			}
		}
		Set<String> pointSet = pointHM.keySet();
		String s = pointSet.toString().substring(1, pointSet.toString().length() - 1);

		String[] arrayKey = s.split("[\\s]*,[\\s]*");

		int keyLen = arrayKey.length;
		int[]point = new int[keyLen];
		for(int i = 0; i < keyLen; i++) {
			point[i] = pointHM.get(arrayKey[i]);
		}


		int v;
		int j;
		String temp;
		for(int i = 1; i < keyLen; i++) {
			v = point[i];
			temp = arrayKey[i];
			j = i - 1;
			while( j >= 0 && arrayKey[j].compareTo(temp) > 0) {
				arrayKey[j + 1] = arrayKey[j];
				point[j + 1] = point[j];
				j--;
			}
			arrayKey[j + 1] = temp;
			point[j + 1] = v;
		}

		for(int i = 1; i < keyLen; i++) {
			v = point[i];
			temp = arrayKey[i];
			j = i - 1;
			while( j >= 0 && point[j] < v) {
				arrayKey[j + 1] = arrayKey[j];
				point[j + 1] = point[j];
				j--;
			}
			arrayKey[j + 1] = temp;
			point[j + 1] = v;
		}
		for(int i = 0; i < 10; i++) {
			System.out.println(arrayKey[i] + " " + point[i]);
		}
	}
}
0