結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー fal_rnd
提出日時 2016-11-18 23:49:59
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,668 bytes
コンパイル時間 2,633 ms
コンパイル使用メモリ 89,204 KB
実行使用メモリ 67,808 KB
最終ジャッジ日時 2024-11-26 08:51:00
合計ジャッジ時間 21,525 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class B{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int[] levels = new int[s.nextInt()],
		      passed = new int[levels.length];
		LinkedList<user> m = new LinkedList<>();
		for (int i = 0; i < levels.length; i++) {
			levels[i]=s.nextInt();
		}
		s.next();
		while(s.hasNext()) {
			String name = s.next();
			int no = s.next().charAt(0)-'A';
			passed[no]++;
			user u = new user(name);
			if(m.contains(u)) {
				m.add(m.get(m.indexOf(u)).addScore(no, getScore(levels[no], passed[no])));
				m.remove(u);
			}else {
				m.add(new user(name,levels.length).addScore(no, getScore(levels[no], passed[no])));
			}
		}
		Collections.sort(m);

		for(int i=m.size()-1;i>=0;--i) {
			user v = m.get(i);
			System.out.printf("%d %s ",m.size()-i,v.name);
			for(int sc:v.score) {
				System.out.printf("%d ",sc);
			}
			System.out.printf("%d\n",v.scoreSum);
		}
	}
	static int getScore(int level, int th) {
		return level*50+(int)(50.0*level/(0.2*th+0.8));
	}

}
class user implements Comparable<user>{
	String name;
	int[] score;
	int scoreSum=0;
	public user(String name,int pros) {
		this.name=name;
		score = new int[pros];
	}
	public user(String name) {
		this(name,1);
	}
	public user addScore(int no,int score) {
		this.score[no]+=score;
		scoreSum+=score;
		return this;
	}
	@Override
	public boolean equals(Object obj) {
		return this.name.equals(((user)obj).name);
	}
	@Override
	public int compareTo(user o) {
		return this.scoreSum-o.scoreSum;
	}
	@Override
	public String toString() {
		return "user [name=" + name + ", score=" + Arrays.toString(score)
				+ ", scoreSum=" + scoreSum + "]";
	}

}
0