AtCoder Beginner Contest 008

Submission #7467398

Source codeソースコード

import java.util.*;

public class Main {
    public static void main(String[] args) {
    	String answer = "";
    	Scanner sc = new Scanner(System.in);
    	int member = sc.nextInt();
    	sc.nextLine();
    	HashMap<String,Integer> hm = new HashMap<String,Integer>();
    	for(int i=0; i<member; i++) {
    		String man = sc.nextLine();
    		if(hm.containsKey(man)) {
    			int num = hm.get(man);
    			hm.put(man, num+1);
    		}
    		else {
    			hm.put(man, 1);
    		}
    	}
    	member = 0;
    	for(String name:hm.keySet()) {
    		if(member < hm.get(name)) {
    			answer = name;
    			member = hm.get(name);
    		}
    	}
    	System.out.println(answer);
    }
}

Submission

Task問題 B - 投票
User nameユーザ名 otako
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 711 Byte
File nameファイル名
Exec time実行時間 99 ms
Memory usageメモリ使用量 25300 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 100 / 100 sample_01.txt,sample_02.txt,sample_03.txt,case_01.txt,case_02.txt,case_03.txt,case_04.txt,case_05.txt,case_06.txt,case_07.txt,case_08.txt,case_09.txt,case_10.txt,case_11.txt,case_12.txt,case_13.txt,case_14.txt,case_15.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
case_01.txt AC 95 ms 20948 KB
case_02.txt AC 93 ms 21204 KB
case_03.txt AC 94 ms 25300 KB
case_04.txt AC 97 ms 21716 KB
case_05.txt AC 93 ms 19412 KB
case_06.txt AC 99 ms 19796 KB
case_07.txt AC 99 ms 21204 KB
case_08.txt AC 97 ms 21204 KB
case_09.txt AC 96 ms 19536 KB
case_10.txt AC 93 ms 17108 KB
case_11.txt AC 97 ms 19024 KB
case_12.txt AC 96 ms 20692 KB
case_13.txt AC 98 ms 19028 KB
case_14.txt AC 95 ms 21844 KB
case_15.txt AC 97 ms 19540 KB
sample_01.txt AC 92 ms 18640 KB
sample_02.txt AC 94 ms 18644 KB
sample_03.txt AC 95 ms 20948 KB