結果

問題 No.281 門松と魔法(1)
ユーザー chocoruskchocorusk
提出日時 2020-09-20 12:52:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 1,000 ms
コード長 652 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-06 16:16:37
合計ジャッジ時間 2,695 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,204 KB
testcase_01 AC 16 ms
8,176 KB
testcase_02 AC 16 ms
8,308 KB
testcase_03 AC 16 ms
8,128 KB
testcase_04 AC 15 ms
8,268 KB
testcase_05 AC 15 ms
8,172 KB
testcase_06 AC 15 ms
8,160 KB
testcase_07 AC 16 ms
8,164 KB
testcase_08 AC 16 ms
8,272 KB
testcase_09 AC 16 ms
8,160 KB
testcase_10 AC 15 ms
8,276 KB
testcase_11 AC 15 ms
8,288 KB
testcase_12 AC 16 ms
8,148 KB
testcase_13 AC 16 ms
8,268 KB
testcase_14 AC 15 ms
8,168 KB
testcase_15 AC 15 ms
8,168 KB
testcase_16 AC 16 ms
8,148 KB
testcase_17 AC 15 ms
8,168 KB
testcase_18 AC 15 ms
8,172 KB
testcase_19 AC 15 ms
8,320 KB
testcase_20 AC 15 ms
8,248 KB
testcase_21 AC 15 ms
8,268 KB
testcase_22 AC 15 ms
8,152 KB
testcase_23 AC 16 ms
8,268 KB
testcase_24 AC 15 ms
8,288 KB
testcase_25 AC 15 ms
8,284 KB
testcase_26 AC 16 ms
8,308 KB
testcase_27 AC 16 ms
8,312 KB
testcase_28 AC 15 ms
8,240 KB
testcase_29 AC 15 ms
8,128 KB
testcase_30 AC 16 ms
8,148 KB
testcase_31 AC 15 ms
8,152 KB
testcase_32 AC 15 ms
8,196 KB
testcase_33 AC 15 ms
8,156 KB
testcase_34 AC 16 ms
8,288 KB
testcase_35 AC 15 ms
8,156 KB
testcase_36 AC 15 ms
8,136 KB
testcase_37 AC 16 ms
8,168 KB
testcase_38 AC 15 ms
8,212 KB
testcase_39 AC 15 ms
8,328 KB
testcase_40 AC 15 ms
8,176 KB
testcase_41 AC 15 ms
8,196 KB
testcase_42 AC 15 ms
8,328 KB
testcase_43 AC 15 ms
8,176 KB
testcase_44 AC 15 ms
8,124 KB
testcase_45 AC 15 ms
8,284 KB
testcase_46 AC 15 ms
8,136 KB
testcase_47 AC 16 ms
8,160 KB
testcase_48 AC 16 ms
8,348 KB
testcase_49 AC 15 ms
8,312 KB
testcase_50 AC 15 ms
8,148 KB
testcase_51 AC 15 ms
8,288 KB
testcase_52 AC 15 ms
8,192 KB
testcase_53 AC 15 ms
8,332 KB
testcase_54 AC 15 ms
8,144 KB
testcase_55 AC 15 ms
8,136 KB
testcase_56 AC 15 ms
8,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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[:]
    if d==0:
        if x[p[0]]>x[p[1]] and x[p[1]]>x[p[2]]:
            print(0)
            exit()
        else:
            continue
    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)
0