結果

問題 No.3681 心の沸騰石
コンテスト
ユーザー Rapca1256
提出日時 2026-09-05 13:58:15
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 92 ms / 2,000 ms
+ 978µs
コード長 1,015 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 849 ms
コンパイル使用メモリ 21,336 KB
実行使用メモリ 15,916 KB
最終ジャッジ日時 2026-09-05 13:59:34
合計ジャッジ時間 4,036 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import math

# 入力高速化
#input = sys.stdin.readline
# 再帰回数上限
sys.setrecursionlimit(10**9)

# よくあるmod
#MOD = 1000000007
MOD = 998244353

def is_inside(y, x, h, w):
  return (0 <= y < h and 0 <= x < w)

def solve():
    R, P, Q = map(int, input().split())
    A, B, C, D = map(int, input().split())
    l = [A, B, C]
    l.sort()
    ans = 0
    tmp1 = min(l[0], R//P)
    tmp2 = 0
    tmp3 = 0
    l[0] -= tmp1
    l[1] -= tmp1
    l[2] -= tmp1
    R -= tmp1 * P
    l.sort()
    if l[1] > 0:
        tmp2 = min(l[1], R // (P+Q), D)
        l[1] -= tmp2
        l[2] -= tmp2
        R -= tmp2 * (P + Q)
        D -= tmp2
    l.sort()
    if l[2] > 0:
        tmp3 = min(l[2], R // (P+2*Q), D//2)
        l[2] -= tmp3
        R -= tmp3 * (P + 2*Q)
        D -= tmp3 * 2
    l.sort()
    tmp4 = min(R // (P+3*Q), D//3)
    R -= tmp4 * (P + 3*Q)
    D -= tmp4 * 3
    print(tmp1 + tmp2 + tmp3 + tmp4)
    
if __name__ == '__main__':
    T = 1
    for _ in range(T):
        solve()
0