結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー lemonlemon
提出日時 2021-03-31 15:21:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 53,984 KB
最終ジャッジ日時 2024-05-08 17:48:17
合計ジャッジ時間 2,625 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,684 KB
testcase_01 AC 37 ms
52,952 KB
testcase_02 AC 36 ms
52,920 KB
testcase_03 AC 38 ms
52,324 KB
testcase_04 AC 37 ms
53,052 KB
testcase_05 AC 38 ms
53,028 KB
testcase_06 AC 37 ms
52,892 KB
testcase_07 AC 38 ms
53,028 KB
testcase_08 AC 39 ms
53,200 KB
testcase_09 AC 42 ms
53,984 KB
testcase_10 AC 38 ms
52,400 KB
testcase_11 AC 37 ms
53,144 KB
testcase_12 AC 37 ms
53,912 KB
testcase_13 AC 37 ms
52,832 KB
testcase_14 AC 38 ms
53,020 KB
testcase_15 AC 37 ms
52,776 KB
testcase_16 AC 37 ms
52,128 KB
testcase_17 AC 38 ms
53,260 KB
testcase_18 AC 37 ms
52,368 KB
testcase_19 AC 38 ms
52,828 KB
testcase_20 AC 36 ms
53,112 KB
testcase_21 AC 37 ms
53,208 KB
testcase_22 AC 37 ms
52,460 KB
testcase_23 AC 38 ms
53,140 KB
testcase_24 AC 37 ms
53,940 KB
testcase_25 AC 37 ms
52,192 KB
testcase_26 AC 38 ms
52,676 KB
testcase_27 AC 39 ms
52,400 KB
testcase_28 AC 37 ms
53,088 KB
testcase_29 AC 37 ms
53,272 KB
testcase_30 AC 36 ms
52,872 KB
testcase_31 AC 37 ms
53,904 KB
testcase_32 AC 38 ms
52,640 KB
testcase_33 AC 37 ms
52,964 KB
testcase_34 AC 37 ms
52,952 KB
testcase_35 AC 38 ms
52,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, itertools
 
sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a, b, n, m = na()

ans = 0
d = 0

def con(a, b, n):
    if (a - b) % (n + 1) == 0:
        return (a - b) // (n + 1) - 1
    
    else:
        return (a - b) // (n + 1) 

if a < b:
    c = con(b, a, m)
    a += c + 1
    b -= m * (c + 1)
    ans = a - 1

    c = con(a, b, n)
    if c != 0:
        d = a - (n * (c + 1))
        a = b + c
    else:
        d = 0
        a = 0
    
        
elif a > b:
    c = con(a, b, n)
    a -= n * (c + 1)
    b += c + 1
    ans = b - 1

    c = con(b, a, m)
    if c != 0:
        d = b - (m * (c + 1))
        b = a + c
    else:
        b = 0
        d = 0

print(max(a, b, ans, d))
0