結果

問題 No.2836 Comment Out
ユーザー hato336hato336
提出日時 2024-08-09 21:38:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 128,896 KB
最終ジャッジ日時 2024-08-09 21:39:12
合計ジャッジ時間 6,739 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,776 KB
testcase_01 AC 38 ms
52,800 KB
testcase_02 AC 39 ms
52,204 KB
testcase_03 AC 38 ms
52,256 KB
testcase_04 AC 37 ms
53,432 KB
testcase_05 AC 38 ms
52,404 KB
testcase_06 AC 36 ms
53,044 KB
testcase_07 AC 101 ms
113,428 KB
testcase_08 AC 89 ms
113,824 KB
testcase_09 AC 158 ms
128,896 KB
testcase_10 AC 157 ms
128,272 KB
testcase_11 AC 156 ms
128,760 KB
testcase_12 AC 160 ms
128,636 KB
testcase_13 AC 157 ms
128,664 KB
testcase_14 AC 94 ms
101,984 KB
testcase_15 AC 96 ms
102,072 KB
testcase_16 AC 93 ms
102,156 KB
testcase_17 AC 157 ms
128,656 KB
testcase_18 AC 95 ms
102,004 KB
testcase_19 AC 159 ms
128,384 KB
testcase_20 AC 94 ms
102,212 KB
testcase_21 AC 97 ms
101,780 KB
testcase_22 AC 160 ms
128,380 KB
testcase_23 AC 160 ms
128,412 KB
testcase_24 AC 63 ms
82,620 KB
testcase_25 AC 75 ms
96,908 KB
testcase_26 AC 55 ms
74,492 KB
testcase_27 AC 72 ms
94,072 KB
testcase_28 AC 139 ms
104,940 KB
testcase_29 AC 72 ms
92,184 KB
testcase_30 AC 58 ms
77,888 KB
testcase_31 AC 69 ms
89,688 KB
testcase_32 AC 99 ms
89,948 KB
testcase_33 AC 63 ms
82,356 KB
testcase_34 AC 54 ms
72,036 KB
testcase_35 AC 77 ms
98,456 KB
testcase_36 AC 119 ms
101,120 KB
testcase_37 AC 78 ms
97,464 KB
testcase_38 AC 65 ms
85,560 KB
testcase_39 AC 128 ms
102,136 KB
testcase_40 AC 134 ms
103,572 KB
testcase_41 AC 72 ms
93,104 KB
testcase_42 AC 147 ms
106,956 KB
testcase_43 AC 50 ms
68,444 KB
testcase_44 AC 38 ms
52,068 KB
testcase_45 AC 38 ms
53,136 KB
testcase_46 AC 36 ms
52,944 KB
testcase_47 AC 38 ms
53,388 KB
testcase_48 AC 37 ms
52,548 KB
testcase_49 AC 37 ms
52,960 KB
testcase_50 AC 37 ms
52,088 KB
testcase_51 AC 38 ms
53,568 KB
testcase_52 AC 38 ms
53,492 KB
testcase_53 AC 38 ms
53,024 KB
testcase_54 AC 37 ms
52,408 KB
testcase_55 AC 37 ms
52,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
if n == 1:
    if a[0] in [0,1]:
        print('Yes')
    else:
        print('No')
    exit()
if min(a) >= 2:
    exit(print('No'))
x = []
temp = [a[0]]
for i in range(1,n):
    if abs(temp[-1] - a[i]) <= 1:
        temp.append(a[i])
    else:
        x.append(temp)
        temp = [a[i]]
if temp:
    x.append(temp)

ans = 'Yes'
for i in x:
    z = max(i)
    y = i.index(z)
    s = set()
    for j in range(y):
        s.add(i[j+1] - i[j])
    if len(s) >= 3 or (1 in s and -1 in s):
        ans = 'No'
    s.discard(0)
    s.discard(-1)
    s.discard(1)
    if len(s) > 0:
        ans = 'No'
    s = set()
    for j in range(y,len(i)-1):
        s.add(i[j+1] - i[j])
    if len(s) >= 3 or (1 in s and -1 in s):
        ans = 'No'
    s.discard(0)
    s.discard(-1)
    s.discard(1)
    if len(s) > 0:
        ans = 'No'
print(ans)
0