結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー lemonlemon
提出日時 2021-03-31 15:07:05
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 80,052 KB
最終ジャッジ日時 2023-08-21 11:55:43
合計ジャッジ時間 5,531 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,200 KB
testcase_01 AC 71 ms
71,124 KB
testcase_02 AC 72 ms
71,108 KB
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 68 ms
71,148 KB
testcase_07 AC 68 ms
70,912 KB
testcase_08 AC 70 ms
71,240 KB
testcase_09 AC 69 ms
70,904 KB
testcase_10 WA -
testcase_11 AC 70 ms
71,188 KB
testcase_12 AC 69 ms
71,060 KB
testcase_13 AC 70 ms
71,148 KB
testcase_14 AC 70 ms
71,040 KB
testcase_15 AC 72 ms
71,164 KB
testcase_16 AC 72 ms
71,304 KB
testcase_17 AC 69 ms
71,156 KB
testcase_18 AC 69 ms
71,132 KB
testcase_19 AC 69 ms
71,132 KB
testcase_20 AC 71 ms
71,332 KB
testcase_21 AC 72 ms
71,288 KB
testcase_22 AC 71 ms
71,144 KB
testcase_23 RE -
testcase_24 AC 72 ms
71,144 KB
testcase_25 RE -
testcase_26 AC 70 ms
71,292 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
testcase_30 AC 69 ms
71,248 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 == 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