結果

問題 No.239 にゃんぱすー
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 22:29:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 74,804 KB
実行使用メモリ 46,760 KB
最終ジャッジ日時 2024-04-24 05:25:37
合計ジャッジ時間 8,840 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
41,588 KB
testcase_01 AC 127 ms
41,620 KB
testcase_02 AC 122 ms
41,568 KB
testcase_03 AC 117 ms
41,496 KB
testcase_04 AC 116 ms
41,444 KB
testcase_05 AC 103 ms
41,496 KB
testcase_06 AC 118 ms
41,356 KB
testcase_07 AC 119 ms
41,448 KB
testcase_08 AC 121 ms
41,888 KB
testcase_09 AC 131 ms
42,068 KB
testcase_10 AC 137 ms
41,608 KB
testcase_11 AC 156 ms
41,848 KB
testcase_12 AC 159 ms
42,372 KB
testcase_13 AC 161 ms
42,200 KB
testcase_14 AC 172 ms
42,660 KB
testcase_15 AC 167 ms
42,692 KB
testcase_16 AC 172 ms
43,228 KB
testcase_17 AC 173 ms
42,808 KB
testcase_18 AC 176 ms
42,908 KB
testcase_19 AC 189 ms
43,632 KB
testcase_20 AC 180 ms
43,940 KB
testcase_21 AC 181 ms
44,744 KB
testcase_22 AC 194 ms
44,236 KB
testcase_23 AC 178 ms
45,308 KB
testcase_24 AC 199 ms
45,828 KB
testcase_25 AC 199 ms
46,760 KB
testcase_26 AC 212 ms
46,568 KB
testcase_27 AC 126 ms
41,480 KB
testcase_28 AC 145 ms
42,152 KB
testcase_29 AC 165 ms
42,812 KB
testcase_30 AC 158 ms
42,608 KB
testcase_31 AC 161 ms
42,424 KB
testcase_32 AC 177 ms
43,080 KB
testcase_33 AC 178 ms
44,260 KB
testcase_34 AC 188 ms
44,364 KB
testcase_35 AC 199 ms
45,504 KB
testcase_36 AC 213 ms
46,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] num = new int[n];
		int max = -1;
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				String s = sc.next();
				if (s.equals("nyanpass") || s.equals("-")) {
					num[j]++;
					max = Math.max(max,num[j]);
				}
			}
		}
		
		//numを回して、maxと同じ値が一つだけあれば、それを出力。
		//複数ある場合、あるいは同じ値がない場合は、-1を出力。
		
		int max_num = 0;
		int renchon = 0;
		for (int i=0; i<n; i++) {
			if (num[i]==n) {
				max_num++;
				renchon = i+1;
			}
		}
		
		if (max_num==0 || max_num >= 2) {System.out.println(-1);}
		else if (max_num==1) {System.out.println(renchon);}
	}
}
0