結果

問題 No.3681 心の沸騰石
コンテスト
ユーザー Takumi1226
提出日時 2026-09-05 15:15:47
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,242 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 95,820 KB
実行使用メモリ 79,380 KB
最終ジャッジ日時 2026-09-05 15:15:52
合計ジャッジ時間 3,128 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import itertools
from functools import cache
import sys
sys.setrecursionlimit(10 ** 9)
import math
from collections import Counter, deque
input = lambda: sys.stdin.readline().rstrip()
mod = 998244353

r, p, q = map(int, input().split())
abcd = list(map(int, input().split()))

people = sum(abcd)
max_romania = people // 3
for i in range(3):
    if max_romania < abcd[i]:
        abcd[3] += abcd[i] - max_romania
        abcd[i] = max_romania

# print(abcd)
abc = abcd[:3]
d = abc[-1]
abc.sort()

# print(abc)
# print(d)

ans = 0
if abc[0] * p <= r:
    # print(abc)
    # print(d)
    # print(r)
    # print("---1")
    ans += abc[0]
    r -= abc[0] * p
    abc[2] -= abc[0]
    abc[1] -= abc[0]
    abc[0] -= abc[0]
    if abc[1] * (q + p) <= r:
        # print(abc)
        # print(d)
        # print(r)
        # print("---2")
        ans += abc[1]
        r -= abc[1] * (q + p)
        abc[2] -= abc[1]
        abc[1] -= abc[1]
        if abc[2] * (2 * q + p) <= r:
            # print(abc)
            # print(d)
            # print(r)
            # print("---3")
            ans += abc[2]
            print(ans)
        else:
            print(ans + r // (2 * q + p))
    else:
        print(ans + r // (q + p))
else:
    print(r // p)
0