結果
| 問題 |
No.1242 高橋君とすごろく
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2020-10-02 21:43:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 1,012 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 52,992 KB |
| 最終ジャッジ日時 | 2024-07-20 02:42:28 |
| 合計ジャッジ時間 | 2,222 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 |
ソースコード
"""
https://yukicoder.me/problems/no/1242
2個の不可能マスが1つの不可能マスを作る
作るのは、1,3,5距離の不可能マスだけ
4つ連続だと確実にアウト
"""
from sys import stdin
import heapq
import sys
N,K = map(int,stdin.readline().split())
A = list(map(int,stdin.readline().split()))
q = []
d = {}
for i in A:
heapq.heappush(q,-1*i)
d[i] = 1
cnt = 0
last = float("inf")
while len(q) > 0:
now = -1 * heapq.heappop(q)
if now < 0:
break
if now == last-1:
cnt += 1
else:
cnt = 1
last = now
if cnt >= 4:
print ("No")
sys.exit()
if now+1 in d and now-3 not in d:
d[now-3] = 1
heapq.heappush(q,-1*(now-3))
if now+3 in d and now-2 not in d:
d[now-2] = 1
heapq.heappush(q,-1*(now-2))
if now+5 in d and now-1 not in d:
d[now-1] = 1
heapq.heappush(q,-1*(now-1))
#print (d)
if 1 not in d:
print ("Yes")
else:
print ("No")
SPD_9X2