結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー lemonlemon
提出日時 2021-03-31 15:18:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 799 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 80,356 KB
最終ジャッジ日時 2023-08-21 12:21:55
合計ジャッジ時間 5,076 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,572 KB
testcase_01 AC 71 ms
71,480 KB
testcase_02 AC 71 ms
71,360 KB
testcase_03 AC 76 ms
71,492 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 70 ms
71,104 KB
testcase_07 AC 71 ms
71,368 KB
testcase_08 AC 71 ms
71,156 KB
testcase_09 AC 72 ms
71,376 KB
testcase_10 AC 71 ms
71,480 KB
testcase_11 AC 71 ms
71,480 KB
testcase_12 AC 70 ms
71,180 KB
testcase_13 AC 71 ms
71,360 KB
testcase_14 AC 72 ms
71,396 KB
testcase_15 AC 72 ms
71,308 KB
testcase_16 AC 73 ms
71,484 KB
testcase_17 AC 72 ms
71,280 KB
testcase_18 AC 72 ms
71,240 KB
testcase_19 AC 70 ms
71,260 KB
testcase_20 AC 71 ms
71,372 KB
testcase_21 AC 72 ms
71,496 KB
testcase_22 AC 73 ms
71,396 KB
testcase_23 RE -
testcase_24 AC 72 ms
71,104 KB
testcase_25 RE -
testcase_26 AC 72 ms
71,312 KB
testcase_27 AC 71 ms
71,316 KB
testcase_28 AC 70 ms
71,468 KB
testcase_29 RE -
testcase_30 AC 70 ms
71,364 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 72 ms
71,484 KB
testcase_34 AC 73 ms
71,484 KB
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) - 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:
        b = a + c
        d = b - (m * (c + 1))
    else:
        b = 0
        d = 0

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