結果

問題 No.628 Tagの勢い
ユーザー fal_rndfal_rnd
提出日時 2018-01-05 23:10:39
言語 Java19
(openjdk 21)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 1,944 bytes
コンパイル時間 4,948 ms
コンパイル使用メモリ 88,516 KB
実行使用メモリ 62,000 KB
最終ジャッジ日時 2023-07-29 14:06:51
合計ジャッジ時間 7,975 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
56,956 KB
testcase_01 AC 167 ms
57,400 KB
testcase_02 AC 158 ms
57,064 KB
testcase_03 AC 169 ms
57,024 KB
testcase_04 AC 160 ms
57,560 KB
testcase_05 AC 162 ms
57,280 KB
testcase_06 AC 162 ms
58,888 KB
testcase_07 AC 167 ms
56,960 KB
testcase_08 AC 177 ms
57,080 KB
testcase_09 AC 165 ms
57,072 KB
testcase_10 AC 200 ms
57,480 KB
testcase_11 AC 176 ms
57,248 KB
testcase_12 AC 286 ms
61,920 KB
testcase_13 AC 285 ms
61,352 KB
testcase_14 AC 278 ms
61,996 KB
testcase_15 AC 285 ms
62,000 KB
testcase_16 AC 268 ms
61,672 KB
testcase_17 AC 162 ms
57,168 KB
testcase_18 AC 165 ms
56,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	private void solve(){
		HashMap<String,Integer>map=new HashMap<>();
		for(int v:rep(gInt())) {
			int no=gInt(),kinds=gInt(),score=gInt();
			strs(kinds).forEach(o->map.merge(o,score,Integer::sum));
		}
		map.entrySet().stream()
		.sorted(Entry.<String,Integer>comparingByValue().reversed()
				.thenComparing(Entry.comparingByKey()))
		.limit(10)
		.map(o->o.getKey()+" "+o.getValue())
		.forEach(System.out::println);
	}

	public static void main(String[]$){
		new Main().solve();
		System.out.flush();
	}

	static class System{
		private static final InputStream in=java.lang.System.in;
		private static final PrintWriter out=new PrintWriter(java.lang.System.out,false);
	}
	static Scanner s=new Scanner(System.in);

	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t){
		return new Range(f,t);
	}
	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
		int from,to,c;
		Range(int from,int to){
			this.from=from;
			this.to=to;
			this.c=from;
		}
		Range(int n){
			this(0,n-1);
		}
		@Override
		public Iterator<Integer> iterator(){
			return this;
		}
		@Override
		public boolean hasNext(){
			return c<=to;
		}
		@Override
		public int nextInt(){
			return c++;
		}
	}

	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}
	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}
}
0