# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
727001 |
2023-04-19T19:19:48 Z |
beaconmc |
Coins (BOI06_coins) |
PyPy 3 |
|
955 ms |
41308 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) if (k-sum)<k else k-1)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
18212 KB |
Output is correct |
2 |
Correct |
40 ms |
18188 KB |
Output is correct |
3 |
Correct |
37 ms |
18176 KB |
Output is correct |
4 |
Correct |
36 ms |
18132 KB |
Output is correct |
5 |
Correct |
52 ms |
18220 KB |
Output is correct |
6 |
Correct |
39 ms |
18184 KB |
Output is correct |
7 |
Correct |
879 ms |
40584 KB |
Output is correct |
8 |
Correct |
905 ms |
40668 KB |
Output is correct |
9 |
Correct |
955 ms |
40152 KB |
Output is correct |
10 |
Correct |
854 ms |
41308 KB |
Output is correct |