結果

問題 No.281 門松と魔法(1)
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-13 13:46:15
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-24 12:02:53
合計ジャッジ時間 1,736 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,272 KB
testcase_01 AC 9 ms
6,272 KB
testcase_02 AC 9 ms
6,144 KB
testcase_03 AC 10 ms
6,272 KB
testcase_04 AC 9 ms
6,272 KB
testcase_05 AC 10 ms
6,272 KB
testcase_06 AC 10 ms
6,144 KB
testcase_07 AC 9 ms
6,272 KB
testcase_08 AC 9 ms
6,272 KB
testcase_09 AC 9 ms
6,272 KB
testcase_10 AC 8 ms
6,144 KB
testcase_11 AC 9 ms
6,272 KB
testcase_12 AC 8 ms
6,272 KB
testcase_13 AC 8 ms
6,272 KB
testcase_14 AC 9 ms
6,272 KB
testcase_15 AC 9 ms
6,272 KB
testcase_16 AC 9 ms
6,272 KB
testcase_17 AC 9 ms
6,272 KB
testcase_18 AC 9 ms
6,144 KB
testcase_19 AC 9 ms
6,272 KB
testcase_20 AC 9 ms
6,272 KB
testcase_21 AC 9 ms
6,144 KB
testcase_22 AC 9 ms
6,272 KB
testcase_23 WA -
testcase_24 AC 8 ms
6,272 KB
testcase_25 WA -
testcase_26 AC 8 ms
6,272 KB
testcase_27 AC 9 ms
6,272 KB
testcase_28 AC 10 ms
6,272 KB
testcase_29 AC 10 ms
6,144 KB
testcase_30 AC 11 ms
6,272 KB
testcase_31 AC 11 ms
6,272 KB
testcase_32 AC 9 ms
6,400 KB
testcase_33 AC 9 ms
6,400 KB
testcase_34 AC 9 ms
6,272 KB
testcase_35 AC 9 ms
6,272 KB
testcase_36 AC 9 ms
6,144 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 8 ms
6,272 KB
testcase_42 AC 9 ms
6,272 KB
testcase_43 AC 9 ms
6,144 KB
testcase_44 WA -
testcase_45 AC 9 ms
6,144 KB
testcase_46 AC 9 ms
6,272 KB
testcase_47 AC 10 ms
6,272 KB
testcase_48 AC 9 ms
6,272 KB
testcase_49 AC 9 ms
6,272 KB
testcase_50 AC 9 ms
6,272 KB
testcase_51 AC 9 ms
6,272 KB
testcase_52 AC 8 ms
6,272 KB
testcase_53 AC 9 ms
6,272 KB
testcase_54 AC 9 ms
6,272 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