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) >= 1 else 1)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
18220 KB |
Output is correct |
2 |
Correct |
38 ms |
18208 KB |
Output is correct |
3 |
Correct |
38 ms |
18180 KB |
Output is correct |
4 |
Correct |
37 ms |
18220 KB |
Output is correct |
5 |
Correct |
44 ms |
18108 KB |
Output is correct |
6 |
Correct |
42 ms |
18224 KB |
Output is correct |
7 |
Correct |
817 ms |
40612 KB |
Output is correct |
8 |
Incorrect |
904 ms |
40604 KB |
Output isn't correct |
9 |
Correct |
849 ms |
40028 KB |
Output is correct |
10 |
Correct |
857 ms |
41244 KB |
Output is correct |