結果
| 問題 |
No.1242 高橋君とすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-02 23:19:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 947 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 54,912 KB |
| 最終ジャッジ日時 | 2024-07-20 02:51:03 |
| 合計ジャッジ時間 | 2,252 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 |
ソースコード
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
from heapq import heapify, heappop as hpp, heappush as hp
h = [-item for item in a]
heapify(h)
ren = 0
from collections import deque
l = []
while h:
v = hpp(h)
v *= -1
# print(l,v)
nl = []
flg = False
for item in l:
d = abs(item-v)
if d==1:
if v-3>=0:
hp(h, -(v-3))
flg = True
elif d==3:
if v-2>=0:
hp(h, -(v-2))
elif d==5:
if v-1>=0:
hp(h, -(v-1))
if 0<=d<5:
nl.append(item)
nl.append(v)
if flg:
ren += 1
else:
ren = 0
l = nl
pv = v
if ren>=4 or v==1:
ans = "No"
break
else:
ans = "Yes"
print(ans)