結果

問題 No.239 にゃんぱすー
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-25 01:55:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 3,755 ms
コンパイル使用メモリ 76,112 KB
実行使用メモリ 39,712 KB
最終ジャッジ日時 2024-05-01 13:19:32
合計ジャッジ時間 7,088 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,616 KB
testcase_01 AC 53 ms
37,044 KB
testcase_02 AC 52 ms
36,888 KB
testcase_03 AC 53 ms
36,952 KB
testcase_04 AC 54 ms
37,292 KB
testcase_05 AC 53 ms
36,968 KB
testcase_06 AC 52 ms
37,108 KB
testcase_07 AC 54 ms
37,108 KB
testcase_08 AC 54 ms
36,828 KB
testcase_09 AC 55 ms
37,032 KB
testcase_10 AC 57 ms
37,236 KB
testcase_11 AC 57 ms
37,040 KB
testcase_12 AC 58 ms
36,780 KB
testcase_13 AC 58 ms
37,104 KB
testcase_14 AC 58 ms
37,180 KB
testcase_15 AC 61 ms
37,388 KB
testcase_16 AC 64 ms
37,360 KB
testcase_17 AC 67 ms
37,592 KB
testcase_18 AC 82 ms
38,156 KB
testcase_19 AC 83 ms
38,168 KB
testcase_20 AC 90 ms
38,720 KB
testcase_21 AC 84 ms
39,240 KB
testcase_22 AC 97 ms
39,324 KB
testcase_23 AC 102 ms
39,280 KB
testcase_24 AC 104 ms
39,044 KB
testcase_25 AC 93 ms
39,292 KB
testcase_26 AC 107 ms
39,672 KB
testcase_27 AC 54 ms
36,860 KB
testcase_28 AC 54 ms
36,948 KB
testcase_29 AC 57 ms
36,780 KB
testcase_30 AC 59 ms
37,288 KB
testcase_31 AC 64 ms
37,336 KB
testcase_32 AC 81 ms
38,152 KB
testcase_33 AC 90 ms
38,564 KB
testcase_34 AC 89 ms
38,748 KB
testcase_35 AC 105 ms
39,484 KB
testcase_36 AC 108 ms
39,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No239{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] pNum = new int[n]; //人数分の配列
		for(int i=0; i < n; i++){
			String[] str = br.readLine().split(" "); //1列毎に分割してString配列に入れる
			for(int j=0; j < str.length; j++){
				if(str[j].equals("nyanpass")){  //配列に入れた文字列が"nyanpass"なら+1
					pNum[j]++;
				}
			}
		}
		int count = 0;
		ShowPersonNumber(n, pNum, count);
	}
	
	public static void ShowPersonNumber(int n, int[] a, int count){
		int ans = 0;
		for(int i=0; i < a.length; i++){
			if(a[i] == (n - 1)){    //(人数-1)回"nyanpasu"と応えた人がいれば
				count++;    //2人以上いないかの確認の変数
				ans = i + 1;   //応えた人はindex "i" +1 番目
			}
		}
		if(count == 1)  System.out.println(ans);  //1人ならその人の番号を表示
		else  System.out.println(-1);  //0人もしくは2人以上なら-1を表示
	}
}
0