結果

問題 No.1242 高橋君とすごろく
ユーザー ks2mks2m
提出日時 2020-10-02 21:53:05
言語 Java19
(openjdk 21)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 2,729 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-09-27 08:38:06
合計ジャッジ時間 7,943 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,784 KB
testcase_01 AC 128 ms
55,524 KB
testcase_02 AC 128 ms
55,884 KB
testcase_03 AC 126 ms
55,824 KB
testcase_04 AC 127 ms
55,572 KB
testcase_05 AC 127 ms
55,384 KB
testcase_06 AC 128 ms
55,544 KB
testcase_07 AC 128 ms
55,748 KB
testcase_08 AC 127 ms
55,416 KB
testcase_09 AC 127 ms
55,356 KB
testcase_10 AC 140 ms
55,416 KB
testcase_11 AC 145 ms
55,548 KB
testcase_12 AC 143 ms
55,404 KB
testcase_13 AC 143 ms
53,548 KB
testcase_14 AC 140 ms
55,772 KB
testcase_15 AC 143 ms
55,544 KB
testcase_16 AC 143 ms
55,372 KB
testcase_17 AC 142 ms
55,724 KB
testcase_18 AC 142 ms
55,620 KB
testcase_19 AC 141 ms
55,772 KB
testcase_20 AC 141 ms
55,572 KB
testcase_21 AC 141 ms
55,832 KB
testcase_22 AC 141 ms
55,744 KB
testcase_23 AC 143 ms
55,744 KB
testcase_24 AC 142 ms
57,756 KB
testcase_25 AC 146 ms
55,344 KB
testcase_26 AC 140 ms
55,700 KB
testcase_27 AC 128 ms
55,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

		boolean[] b = new boolean[30];
		for (int i = 0; i < k; i++) {
			if (a[i] < 25) {
				int c = (int) a[i];
				b[c] = true;
			} else {
				int start = i;
				if (i > 0 && a[i - 1] > 20) {
					start--;
				}
				for (int j = start; j < k; j++) {
					for (int j2 = j + 1; j2 < k; j2++) {
						if (a[j] + 1 == a[j2] || a[j] + 3 == a[j2] || a[j] + 5 == a[j2]) {
							System.out.println("No");
							return;
						}
					}
				}
				break;
			}
		}
		for (int i = 24; i >= 0; i--) {
			if (b[i + 1] && b[i + 6]) {
				b[i] = true;
			}
			if (b[i + 2] && b[i + 5]) {
				b[i] = true;
			}
			if (b[i + 3] && b[i + 4]) {
				b[i] = true;
			}
		}
		if (b[1]) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}
0