結果
問題 | No.2836 Comment Out |
ユーザー |
|
提出日時 | 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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 52 |
ソースコード
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)