結果

問題 No.2836 Comment Out
ユーザー Shirotsume
提出日時 2024-08-09 21:42:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 125,808 KB
最終ジャッジ日時 2024-08-09 21:42:12
合計ジャッジ時間 7,520 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
import logging
from logging import debug, error, info, warning
logging.basicConfig(level=logging.DEBUG)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

n = ii()
a = [0] + li() + [0]
for i in range(len(a)):
    if (i + 1 < len(a) and abs(a[i] - a[i + 1]) <= 1) or (i - 1 >= 0 and abs(a[i] - a[i - 1]) <= 1):
        pass
    else:
        print("No")
        exit()
A = []
for i in range(n + 1):
    A.append(a[i + 1] - a[i])
cnt = 0
ans = 'Yes'
for i in range(len(A)):
    cnt += A[i]
    if cnt < 0:
        ans = 'No'
        break
if cnt != 0:
    ans = 'No'
print(ans)
0