| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1336476 | nguyengiabach1201 | Coins (BOI06_coins) | Pypy 3 | 150 ms | 48764 KiB |
def solve():
# Read N and K
N, K = map(int, input().split())
coins = []
for _ in range(N):
coins.append(list(map(int, input().split())))
current_sum = 0
new_coin_count = 0
for i in range(N):
val, already_owned = coins[i]
# Determine the upper bound for the current sum
limit = coins[i+1][0] if i + 1 < N else K
if already_owned == 0:
# If we don't have this coin, try to add it
if current_sum + val < limit:
current_sum += val
new_coin_count += 1
else:
# If we already have it, we skip it to keep the sum minimal.
# However, we must ensure our existing sum is still valid
# for the current limit (which it will be, since current_sum < val < limit)
pass
# Special case: if no new coins can be acquired, the best price is K-1
if new_coin_count == 0:
print(0)
print(K - 1)
else:
print(new_coin_count)
print(K - current_sum)컴파일 시 표준 출력 (stdout) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
