結果

問題 No.281 門松と魔法(1)
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-13 13:48:14
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 6,124 KB
最終ジャッジ日時 2023-08-06 16:50:28
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,080 KB
testcase_01 AC 11 ms
5,920 KB
testcase_02 AC 11 ms
6,084 KB
testcase_03 AC 11 ms
5,848 KB
testcase_04 AC 11 ms
5,936 KB
testcase_05 AC 11 ms
6,116 KB
testcase_06 AC 11 ms
5,856 KB
testcase_07 AC 11 ms
5,984 KB
testcase_08 AC 11 ms
5,856 KB
testcase_09 AC 11 ms
5,920 KB
testcase_10 AC 11 ms
5,848 KB
testcase_11 AC 11 ms
5,924 KB
testcase_12 AC 11 ms
5,848 KB
testcase_13 AC 12 ms
5,856 KB
testcase_14 AC 11 ms
5,940 KB
testcase_15 AC 11 ms
5,924 KB
testcase_16 AC 10 ms
6,080 KB
testcase_17 AC 11 ms
5,984 KB
testcase_18 AC 11 ms
5,984 KB
testcase_19 AC 11 ms
5,844 KB
testcase_20 AC 11 ms
5,880 KB
testcase_21 AC 11 ms
5,836 KB
testcase_22 AC 11 ms
6,008 KB
testcase_23 AC 11 ms
5,908 KB
testcase_24 AC 11 ms
5,880 KB
testcase_25 AC 11 ms
5,944 KB
testcase_26 AC 11 ms
6,092 KB
testcase_27 AC 11 ms
5,836 KB
testcase_28 AC 11 ms
5,884 KB
testcase_29 AC 11 ms
5,932 KB
testcase_30 AC 12 ms
6,120 KB
testcase_31 AC 12 ms
5,920 KB
testcase_32 AC 11 ms
5,884 KB
testcase_33 AC 11 ms
6,076 KB
testcase_34 AC 11 ms
5,876 KB
testcase_35 AC 11 ms
5,944 KB
testcase_36 AC 11 ms
5,856 KB
testcase_37 AC 11 ms
6,088 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 11 ms
6,040 KB
testcase_41 AC 11 ms
6,036 KB
testcase_42 AC 11 ms
5,880 KB
testcase_43 AC 11 ms
6,120 KB
testcase_44 AC 11 ms
5,848 KB
testcase_45 AC 10 ms
5,884 KB
testcase_46 AC 11 ms
6,080 KB
testcase_47 AC 11 ms
6,080 KB
testcase_48 AC 11 ms
6,044 KB
testcase_49 AC 10 ms
5,988 KB
testcase_50 AC 11 ms
5,940 KB
testcase_51 AC 10 ms
6,000 KB
testcase_52 AC 11 ms
5,836 KB
testcase_53 AC 10 ms
6,004 KB
testcase_54 AC 10 ms
5,908 KB
testcase_55 AC 11 ms
5,876 KB
testcase_56 AC 11 ms
5,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

d=int(raw_input())
H1=int(raw_input())
H2=int(raw_input())
H3=int(raw_input())
def kadomatsu(h1,h2,h3):
    if h1<h2 and h2>h3 and h1!=h3:
        return True
    if h1>h2 and h2<h3 and h1!=h3:
        return True
    return False

if kadomatsu(H1,H2,H3):
    print 0
    exit()
if d==0:
    print -1
    exit()
if H3<H1:
   H3,H1=H1,H3 

ans=3000000000
# case H1<H2>H3
t1,t2=max(0,(H1-H2+d)/d),max(0,(H3-H2+d)/d)
h1,h3=max(0,H1-t1*d),max(0,H3-t2*d)
if kadomatsu(h1,H2,h3):
    #print t1,"+",t2
    ans=min(ans,t1+t2)
elif h3>0 and max(h3-d,0)!=h1:
    #print t1,"+",t2,"+1"
    ans=min(ans,t1+t2+1)

# case H1>H2<H3
if H1==H3:
    H1=max(0,H1-d)
t1=(H2-H1+d)/d
h2=max(0,H2-t1*d)
if kadomatsu(H1,h2,H3):
    #print t1
    ans=min(ans,t1)
if ans==3000000000:
    ans=-1
print ans
0