結果
問題 |
No.281 門松と魔法(1)
|
ユーザー |
![]() |
提出日時 | 2020-09-20 12:46:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 491 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-24 10:42:09 |
合計ジャッジ時間 | 3,458 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 WA * 9 RE * 10 |
ソースコード
import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines d=int(readline()) h=list(map(int, read().split())) INF=10**10 ans=INF import itertools for p in itertools.permutations(range(3)): if p[0]!=1 and p[2]!=1: continue x=h[:] c1=max(0, (x[p[1]]-x[p[0]])//d+1) x[p[1]]-=c1*d if x[p[1]]<0: continue c2=max(0, (x[p[2]]-x[p[1]])//d+1) x[p[2]]-=c2*d if x[p[2]]<0: continue ans=min(ans, c1+c2) if ans==INF: print(-1) else: print(ans)