結果
問題 |
No.2836 Comment Out
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:26:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,008 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 82,020 KB |
実行使用メモリ | 105,980 KB |
最終ジャッジ日時 | 2025-06-12 20:26:51 |
合計ジャッジ時間 | 5,773 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 WA * 26 |
ソースコード
def main(): import sys input = sys.stdin.read().split() n = int(input[0]) a = list(map(int, input[1:n+1])) if n == 1: print("Yes") return # Check if all consecutive differences are <=1 in absolute value for i in range(n-1): if abs(a[i+1] - a[i]) > 1: print("No") return # Check if it's a mountain array # Find the peak peak = -1 for i in range(1, n): if a[i] > a[i-1]: continue else: peak = i-1 break else: # All increasing peak = n-1 # Check if all elements after peak are strictly decreasing for i in range(peak, n-1): if a[i] <= a[i+1]: print("No") return # Check if all elements before peak are strictly increasing for i in range(peak): if a[i] >= a[i+1]: print("No") return print("Yes") if __name__ == "__main__": main()