結果

問題 No.1053 ゲーミング棒
ユーザー ks2mks2m
提出日時 2020-05-15 22:02:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 3,867 ms
コンパイル使用メモリ 74,340 KB
実行使用メモリ 62,420 KB
最終ジャッジ日時 2023-10-19 14:23:18
合計ジャッジ時間 13,647 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
56,824 KB
testcase_01 AC 129 ms
55,788 KB
testcase_02 AC 125 ms
57,560 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 114 ms
56,188 KB
testcase_06 AC 123 ms
57,544 KB
testcase_07 AC 123 ms
57,580 KB
testcase_08 AC 114 ms
56,176 KB
testcase_09 AC 124 ms
57,680 KB
testcase_10 AC 126 ms
57,312 KB
testcase_11 AC 112 ms
56,256 KB
testcase_12 AC 117 ms
55,744 KB
testcase_13 AC 124 ms
57,828 KB
testcase_14 AC 124 ms
57,632 KB
testcase_15 AC 125 ms
57,584 KB
testcase_16 AC 125 ms
57,796 KB
testcase_17 AC 111 ms
56,228 KB
testcase_18 AC 121 ms
57,392 KB
testcase_19 AC 127 ms
57,164 KB
testcase_20 AC 123 ms
57,428 KB
testcase_21 AC 122 ms
57,732 KB
testcase_22 AC 125 ms
57,540 KB
testcase_23 AC 503 ms
62,044 KB
testcase_24 AC 461 ms
61,068 KB
testcase_25 AC 488 ms
60,156 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 123 ms
57,548 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 471 ms
61,888 KB
testcase_34 AC 436 ms
61,616 KB
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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) {
				System.out.println(-1);
				return;
			}
			c[a[i]]++;
		}
		if (a[0] == a[n - 1]) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}
0