結果

問題 No.1015 おつりは要らないです
ユーザー lam6er
提出日時 2025-04-09 20:56:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,271 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,412 KB
実行使用メモリ 96,148 KB
最終ジャッジ日時 2025-04-09 20:56:29
合計ジャッジ時間 4,485 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    X = int(input[idx])
    idx += 1
    Y = int(input[idx])
    idx += 1
    Z = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    
    x, y, z = X, Y, Z
    
    for a_i in A:
        required_k = (a_i + 999) // 1000
        # Ensure required_k is strictly greater than a_i / 1000
        while required_k * 1000 <= a_i:
            required_k += 1
        
        total_money = x * 1000 + y * 5000 + z * 10000
        
        while True:
            if required_k * 1000 > total_money:
                print("No")
                return
            
            # Compute max possible c
            use_c = min(z, required_k // 10)
            rem_k = required_k - use_c * 10
            # Compute max possible b
            use_b = min(y, rem_k // 5)
            rem_k -= use_b * 5
            # Required a is rem_k
            use_a = rem_k
            
            if use_a <= x:
                # Update the wallet
                z -= use_c
                y -= use_b
                x -= use_a
                break
            else:
                required_k += 1
    
    print("Yes")

if __name__ == '__main__':
    main()
0