結果

問題 No.239 にゃんぱすー
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 22:21:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 46,516 KB
最終ジャッジ日時 2024-04-24 03:14:25
合計ジャッジ時間 10,482 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,056 KB
testcase_01 AC 120 ms
39,972 KB
testcase_02 AC 133 ms
40,916 KB
testcase_03 AC 135 ms
41,176 KB
testcase_04 AC 132 ms
41,404 KB
testcase_05 AC 130 ms
41,380 KB
testcase_06 AC 130 ms
41,328 KB
testcase_07 AC 137 ms
41,200 KB
testcase_08 AC 142 ms
41,200 KB
testcase_09 AC 146 ms
41,428 KB
testcase_10 AC 160 ms
41,500 KB
testcase_11 AC 170 ms
41,796 KB
testcase_12 AC 181 ms
42,036 KB
testcase_13 AC 185 ms
41,892 KB
testcase_14 AC 186 ms
42,160 KB
testcase_15 AC 189 ms
41,980 KB
testcase_16 AC 191 ms
42,240 KB
testcase_17 AC 196 ms
42,356 KB
testcase_18 AC 200 ms
42,684 KB
testcase_19 AC 199 ms
43,116 KB
testcase_20 AC 205 ms
43,644 KB
testcase_21 AC 212 ms
43,876 KB
testcase_22 AC 209 ms
43,956 KB
testcase_23 AC 218 ms
44,968 KB
testcase_24 AC 227 ms
45,716 KB
testcase_25 AC 231 ms
45,952 KB
testcase_26 AC 233 ms
45,980 KB
testcase_27 AC 140 ms
40,964 KB
testcase_28 AC 170 ms
41,628 KB
testcase_29 AC 179 ms
41,832 KB
testcase_30 WA -
testcase_31 AC 185 ms
42,492 KB
testcase_32 AC 202 ms
43,036 KB
testcase_33 AC 211 ms
43,628 KB
testcase_34 AC 216 ms
44,264 KB
testcase_35 AC 223 ms
45,656 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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]==max) {
				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