結果
| 問題 | No.3509 Get More Money |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 16:59:41 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,359 bytes |
| 記録 | |
| コンパイル時間 | 697 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 58,332 KB |
| 最終ジャッジ日時 | 2026-04-18 17:00:31 |
| 合計ジャッジ時間 | 37,789 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 60 |
ソースコード
import heapq
import sys
input = sys.stdin.readline
def solve():
T = int(input())
for _ in range(T):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = list(map(int, input().split()))
heap = [] # (cost, count)
total = 0
gold = 100 # initial
for i in range(N):
# BUY phase
if B[i] > 0:
heapq.heappush(heap, (A[i], B[i]))
total += B[i]
# enforce storage limit K
while total > K:
cost, cnt = heapq.heappop(heap)
if cnt > total - K:
heapq.heappush(heap, (cost, cnt - (total - K)))
total = K
else:
total -= cnt
# SELL phase
sell = D[i]
price = C[i]
while sell > 0 and heap:
cost, cnt = heapq.heappop(heap)
take = min(cnt, sell)
gold += take * (price - cost)
cnt -= take
sell -= take
total -= take
if cnt > 0:
heapq.heappush(heap, (cost, cnt))
print(gold - 100)
if __name__ == "__main__":
solve()