結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー lemonlemon
提出日時 2021-03-31 15:21:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 71,340 KB
最終ジャッジ日時 2023-08-21 12:29:38
合計ジャッジ時間 4,520 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,240 KB
testcase_01 AC 70 ms
71,056 KB
testcase_02 AC 71 ms
70,988 KB
testcase_03 AC 69 ms
71,000 KB
testcase_04 AC 71 ms
71,204 KB
testcase_05 AC 71 ms
71,300 KB
testcase_06 AC 73 ms
70,988 KB
testcase_07 AC 71 ms
71,180 KB
testcase_08 AC 72 ms
71,108 KB
testcase_09 AC 72 ms
70,968 KB
testcase_10 AC 71 ms
70,964 KB
testcase_11 AC 72 ms
71,244 KB
testcase_12 AC 72 ms
71,304 KB
testcase_13 AC 71 ms
71,112 KB
testcase_14 AC 71 ms
70,980 KB
testcase_15 AC 74 ms
71,052 KB
testcase_16 AC 72 ms
71,144 KB
testcase_17 AC 76 ms
71,148 KB
testcase_18 AC 75 ms
70,992 KB
testcase_19 AC 75 ms
70,988 KB
testcase_20 AC 77 ms
71,272 KB
testcase_21 AC 77 ms
71,328 KB
testcase_22 AC 76 ms
70,964 KB
testcase_23 AC 74 ms
71,184 KB
testcase_24 AC 75 ms
71,096 KB
testcase_25 AC 74 ms
71,156 KB
testcase_26 AC 76 ms
71,268 KB
testcase_27 AC 76 ms
71,176 KB
testcase_28 AC 76 ms
71,052 KB
testcase_29 AC 75 ms
71,180 KB
testcase_30 AC 76 ms
71,304 KB
testcase_31 AC 75 ms
71,340 KB
testcase_32 AC 75 ms
71,260 KB
testcase_33 AC 75 ms
71,172 KB
testcase_34 AC 74 ms
71,224 KB
testcase_35 AC 75 ms
71,240 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