結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー lemonlemon
提出日時 2021-03-31 15:16:04
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 80,156 KB
最終ジャッジ日時 2023-08-21 12:18:01
合計ジャッジ時間 5,209 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 73 ms
71,204 KB
testcase_02 AC 72 ms
71,292 KB
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 71 ms
71,184 KB
testcase_07 AC 72 ms
71,344 KB
testcase_08 AC 71 ms
71,228 KB
testcase_09 AC 72 ms
71,192 KB
testcase_10 WA -
testcase_11 AC 71 ms
71,088 KB
testcase_12 AC 72 ms
71,324 KB
testcase_13 AC 70 ms
71,340 KB
testcase_14 AC 71 ms
71,224 KB
testcase_15 AC 71 ms
71,192 KB
testcase_16 AC 69 ms
71,328 KB
testcase_17 AC 71 ms
71,256 KB
testcase_18 AC 71 ms
71,148 KB
testcase_19 AC 70 ms
71,288 KB
testcase_20 AC 71 ms
71,148 KB
testcase_21 AC 71 ms
71,088 KB
testcase_22 AC 72 ms
71,248 KB
testcase_23 RE -
testcase_24 WA -
testcase_25 RE -
testcase_26 AC 73 ms
71,292 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
testcase_30 AC 71 ms
71,184 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 WA -
testcase_34 WA -
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

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()

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

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:
        b = a + c
        d = b - (m * (c + 1))
    else:
        b = 0
        d = 0

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