結果

問題 No.149 碁石の移動
ユーザー lam6er
提出日時 2025-03-20 20:28:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 53,672 KB
最終ジャッジ日時 2025-03-20 20:29:39
合計ジャッジ時間 1,404 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

# 入力の読み込み
A_w, A_b = map(int, input().split())
B_w, B_b = map(int, input().split())
C, D = map(int, input().split())

# 取り得る白石の数の最小値と最大値を計算
x_min = max(0, C - A_b)
x_max = min(C, A_w)

# 各ケースを判定
case1 = (B_w + x_max) <= D
case2 = (B_w + x_min) >= D

if case1:
    max_white = A_w + B_w
elif case2:
    max_white = (A_w - x_min) + D
else:
    max_white = A_w + B_w

print(max_white)
0