結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-09-20 12:51:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 113 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-06-24 10:42:19 |
| 合計ジャッジ時間 | 3,173 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 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
if d==0:
if x[p[0]]>x[p[1]] and x[p[1]]>x[p[2]]:
print(0)
exit()
else:
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
ans=min(ans, c1+c2)
if ans==INF:
print(-1)
else:
print(ans)
chocorusk