結果

問題 No.1053 ゲーミング棒
ユーザー ks2mks2m
提出日時 2020-05-15 22:06:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 77,480 KB
実行使用メモリ 62,164 KB
最終ジャッジ日時 2023-10-19 14:30:21
合計ジャッジ時間 13,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
57,484 KB
testcase_01 AC 135 ms
57,656 KB
testcase_02 AC 137 ms
57,580 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 137 ms
55,568 KB
testcase_06 AC 137 ms
57,416 KB
testcase_07 AC 133 ms
57,084 KB
testcase_08 AC 148 ms
57,624 KB
testcase_09 AC 138 ms
57,076 KB
testcase_10 AC 137 ms
57,748 KB
testcase_11 AC 134 ms
57,152 KB
testcase_12 AC 136 ms
57,396 KB
testcase_13 AC 134 ms
57,380 KB
testcase_14 AC 137 ms
57,388 KB
testcase_15 AC 137 ms
57,084 KB
testcase_16 AC 139 ms
57,480 KB
testcase_17 AC 133 ms
57,132 KB
testcase_18 AC 136 ms
57,068 KB
testcase_19 AC 140 ms
57,120 KB
testcase_20 AC 135 ms
57,516 KB
testcase_21 AC 136 ms
57,368 KB
testcase_22 AC 134 ms
57,360 KB
testcase_23 AC 543 ms
61,956 KB
testcase_24 AC 542 ms
62,060 KB
testcase_25 AC 534 ms
61,888 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 134 ms
57,104 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 498 ms
61,752 KB
testcase_32 AC 514 ms
61,796 KB
testcase_33 AC 506 ms
61,892 KB
testcase_34 AC 511 ms
61,932 KB
testcase_35 AC 540 ms
62,076 KB
testcase_36 AC 537 ms
60,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int[] c = new int[n + 1];
		c[a[0]]++;
		for (int i = 1; i < n - 1; i++) {
			if (a[i] != a[i - 1] && c[a[i]] > 0) {
				for (int j = i + 1; j < n; j++) {
					if (a[i] != a[j]) {
						System.out.println(-1);
						return;
					}
				}
				System.out.println(1);
				return;
			}
			c[a[i]]++;
		}
		if (a[0] == a[n - 1]) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}
0