結果
| 問題 |
No.2836 Comment Out
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:18:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,008 bytes |
| コンパイル時間 | 185 ms |
| コンパイル使用メモリ | 83,020 KB |
| 実行使用メモリ | 106,280 KB |
| 最終ジャッジ日時 | 2025-06-12 15:19:03 |
| 合計ジャッジ時間 | 5,743 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
gew1fw