結果

問題 No.239 にゃんぱすー
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-25 01:55:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 3,883 ms
コンパイル使用メモリ 74,056 KB
実行使用メモリ 52,456 KB
最終ジャッジ日時 2023-08-13 23:45:53
合計ジャッジ時間 7,831 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,508 KB
testcase_01 AC 43 ms
49,196 KB
testcase_02 AC 42 ms
49,240 KB
testcase_03 AC 43 ms
49,296 KB
testcase_04 AC 43 ms
49,104 KB
testcase_05 AC 44 ms
49,664 KB
testcase_06 AC 43 ms
47,176 KB
testcase_07 AC 43 ms
49,324 KB
testcase_08 AC 43 ms
49,312 KB
testcase_09 AC 44 ms
49,672 KB
testcase_10 AC 45 ms
49,472 KB
testcase_11 AC 47 ms
49,500 KB
testcase_12 AC 50 ms
49,352 KB
testcase_13 AC 52 ms
49,468 KB
testcase_14 AC 53 ms
49,692 KB
testcase_15 AC 54 ms
49,492 KB
testcase_16 AC 55 ms
50,404 KB
testcase_17 AC 56 ms
50,784 KB
testcase_18 AC 61 ms
50,968 KB
testcase_19 AC 66 ms
50,632 KB
testcase_20 AC 70 ms
50,836 KB
testcase_21 AC 71 ms
51,172 KB
testcase_22 AC 73 ms
51,520 KB
testcase_23 AC 78 ms
51,744 KB
testcase_24 AC 91 ms
51,864 KB
testcase_25 AC 79 ms
51,352 KB
testcase_26 AC 83 ms
51,444 KB
testcase_27 AC 43 ms
49,672 KB
testcase_28 AC 46 ms
49,320 KB
testcase_29 AC 50 ms
49,648 KB
testcase_30 AC 52 ms
49,376 KB
testcase_31 AC 55 ms
50,204 KB
testcase_32 AC 58 ms
50,540 KB
testcase_33 AC 70 ms
50,824 KB
testcase_34 AC 73 ms
52,456 KB
testcase_35 AC 79 ms
51,812 KB
testcase_36 AC 96 ms
51,984 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