Submission #726997

# Submission time Handle Problem Language Result Execution time Memory
726997 2023-04-19T19:17:35 Z beaconmc Coins (BOI06_coins) PyPy 3
90 / 100
892 ms 41416 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 and have[-1]==0:
    ans += 1
    sum += coins[-1]
print(ans)
print(k-sum)

# Verdict Execution time Memory Grader output
1 Correct 41 ms 18256 KB Output is correct
2 Correct 40 ms 18208 KB Output is correct
3 Correct 40 ms 18196 KB Output is correct
4 Correct 41 ms 18180 KB Output is correct
5 Correct 43 ms 18228 KB Output is correct
6 Correct 38 ms 18232 KB Output is correct
7 Correct 838 ms 40664 KB Output is correct
8 Incorrect 829 ms 40620 KB Output isn't correct
9 Correct 869 ms 40620 KB Output is correct
10 Correct 892 ms 41416 KB Output is correct