結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
37,176 KB
testcase_01 AC 50 ms
37,148 KB
testcase_02 AC 48 ms
37,104 KB
testcase_03 AC 48 ms
36,636 KB
testcase_04 AC 50 ms
36,944 KB
testcase_05 AC 48 ms
36,624 KB
testcase_06 AC 49 ms
36,768 KB
testcase_07 AC 48 ms
37,148 KB
testcase_08 AC 48 ms
37,100 KB
testcase_09 AC 48 ms
37,248 KB
testcase_10 AC 49 ms
36,956 KB
testcase_11 AC 53 ms
37,176 KB
testcase_12 AC 53 ms
37,260 KB
testcase_13 AC 53 ms
37,172 KB
testcase_14 AC 55 ms
37,288 KB
testcase_15 AC 58 ms
37,320 KB
testcase_16 AC 63 ms
37,432 KB
testcase_17 AC 63 ms
37,672 KB
testcase_18 AC 74 ms
38,188 KB
testcase_19 AC 66 ms
38,496 KB
testcase_20 AC 72 ms
38,600 KB
testcase_21 AC 81 ms
38,812 KB
testcase_22 AC 93 ms
38,816 KB
testcase_23 AC 83 ms
39,104 KB
testcase_24 AC 94 ms
39,028 KB
testcase_25 AC 94 ms
39,336 KB
testcase_26 AC 99 ms
39,648 KB
testcase_27 AC 49 ms
36,964 KB
testcase_28 AC 47 ms
37,112 KB
testcase_29 AC 55 ms
37,176 KB
testcase_30 AC 51 ms
36,772 KB
testcase_31 AC 55 ms
37,604 KB
testcase_32 AC 73 ms
38,092 KB
testcase_33 AC 70 ms
38,448 KB
testcase_34 AC 93 ms
38,824 KB
testcase_35 AC 102 ms
39,344 KB
testcase_36 AC 95 ms
39,548 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