結果

問題 No.281 門松と魔法(1)
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-13 13:46:15
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 6,596 KB
実行使用メモリ 6,136 KB
最終ジャッジ日時 2023-08-06 16:50:26
合計ジャッジ時間 2,666 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,844 KB
testcase_01 AC 11 ms
5,852 KB
testcase_02 AC 11 ms
5,864 KB
testcase_03 AC 11 ms
6,012 KB
testcase_04 AC 11 ms
5,916 KB
testcase_05 AC 11 ms
5,860 KB
testcase_06 AC 11 ms
6,076 KB
testcase_07 AC 11 ms
5,844 KB
testcase_08 AC 11 ms
6,028 KB
testcase_09 AC 11 ms
6,012 KB
testcase_10 AC 11 ms
6,000 KB
testcase_11 AC 11 ms
5,896 KB
testcase_12 AC 11 ms
5,944 KB
testcase_13 AC 11 ms
5,980 KB
testcase_14 AC 11 ms
5,984 KB
testcase_15 AC 11 ms
6,008 KB
testcase_16 AC 11 ms
5,960 KB
testcase_17 AC 11 ms
5,880 KB
testcase_18 AC 11 ms
5,936 KB
testcase_19 AC 11 ms
6,000 KB
testcase_20 AC 11 ms
5,848 KB
testcase_21 AC 10 ms
6,132 KB
testcase_22 AC 11 ms
6,136 KB
testcase_23 WA -
testcase_24 AC 11 ms
5,856 KB
testcase_25 WA -
testcase_26 AC 11 ms
6,020 KB
testcase_27 AC 11 ms
5,844 KB
testcase_28 AC 11 ms
5,868 KB
testcase_29 AC 10 ms
5,952 KB
testcase_30 AC 11 ms
5,940 KB
testcase_31 AC 10 ms
6,080 KB
testcase_32 AC 10 ms
5,940 KB
testcase_33 AC 10 ms
6,128 KB
testcase_34 AC 11 ms
5,980 KB
testcase_35 AC 11 ms
5,892 KB
testcase_36 AC 10 ms
6,072 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 11 ms
5,944 KB
testcase_42 AC 11 ms
6,000 KB
testcase_43 AC 11 ms
5,864 KB
testcase_44 WA -
testcase_45 AC 11 ms
5,924 KB
testcase_46 AC 11 ms
5,932 KB
testcase_47 AC 10 ms
5,916 KB
testcase_48 AC 11 ms
5,960 KB
testcase_49 AC 10 ms
6,072 KB
testcase_50 AC 11 ms
5,980 KB
testcase_51 AC 11 ms
6,084 KB
testcase_52 AC 11 ms
5,936 KB
testcase_53 AC 11 ms
5,844 KB
testcase_54 AC 10 ms
5,940 KB
testcase_55 WA -
testcase_56 WA -
権限があれば一括ダウンロードができます

ソースコード

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):
    ans=min(ans,t1+t2)
elif h3>0 and max(h3-d,0)!=h1:
    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,t1*d)
if kadomatsu(H1,h2,H3):
    ans=min(ans,t1)
if ans==3000000000:
    ans=-1
print ans
0