結果
問題 | No.281 門松と魔法(1) |
ユーザー |
![]() |
提出日時 | 2022-10-03 02:25:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,163 bytes |
コンパイル時間 | 458 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-12-26 03:28:19 |
合計ジャッジ時間 | 5,170 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 WA * 9 RE * 10 |
ソースコード
from ast import Modimport bisectimport copyimport decimalimport fractionsimport heapqimport itertoolsimport mathimport randomimport sysimport timefrom collections import Counter,deque,defaultdictfrom functools import lru_cache,reducefrom heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_maxdef _heappush_max(heap,item):heap.append(item)heapq._siftdown_max(heap, 0, len(heap)-1)def _heappushpop_max(heap, item):if heap and item < heap[0]:item, heap[0] = heap[0], itemheapq._siftup_max(heap, 0)return itemfrom math import gcd as GCDread=sys.stdin.readreadline=sys.stdin.readlinereadlines=sys.stdin.readlineswrite=sys.stdout.writeD=int(readline())H=[int(readline()) for _ in range(3)]inf=1<<60ans=inffor tpl in itertools.permutations([0,1,2]):if tpl[1]==1:continuecnt=0HH=H[:]for a,b in zip(tpl[:-1],tpl[1:]):if HH[a]<=HH[b]:c=(HH[b]-HH[a])//D+1HH[b]-=c*Dcnt+=cif len(set(HH))==3 and HH[1] in (min(HH),max(HH)) and all(h>=0 for h in HH):ans=min(ans,cnt)if ans==inf:ans=-1print(ans)