Submission #727001

#TimeUsernameProblemLanguageResultExecution timeMemory
727001beaconmcCoins (BOI06_coins)Pypy 3
100 / 100
955 ms41308 KiB
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) if (k-sum)<k else k-1)
#Verdict Execution timeMemoryGrader output
Fetching results...