답안 #726996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
726996 2023-04-19T19:17:04 Z beaconmc Coins (BOI06_coins) PyPy 3
90 / 100
906 ms 41380 KB
n,k = map(int, input().split())

coins = []
have = []

for i in range(n):
    a,b = map(int, input().split())
    coins.append(a)
    have.append(b)

ans = 0
sum = 0

for i in range(len(coins)-1):
    if have[i]==0 and sum + coins[i] < coins[i+1] and sum+coins[i] < k:
        ans += 1
        sum += coins[i]
if sum+coins[-1] < k:
    ans += 1
    sum += coins[-1]
print(ans)
print(k-sum)

# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 18120 KB Output is correct
2 Correct 49 ms 18172 KB Output is correct
3 Correct 36 ms 18184 KB Output is correct
4 Correct 38 ms 18256 KB Output is correct
5 Correct 38 ms 18196 KB Output is correct
6 Correct 39 ms 18220 KB Output is correct
7 Correct 906 ms 40628 KB Output is correct
8 Incorrect 845 ms 40580 KB Output isn't correct
9 Correct 875 ms 40072 KB Output is correct
10 Correct 855 ms 41380 KB Output is correct