H=print
G=range
F=input
I,C=map(int,F().split())
A=[]
D=[]
for B in G(I):J,K=map(int,F().split());A.append(J);D.append(K)
E=0
sum=0
for B in G(len(A)-1):
if D[B]==0 and sum+A[B]<A[B+1]and sum+A[B]<C:E+=1;sum+=A[B]
if sum+A[-1]<C and D[-1]==0:E+=1;sum+=A[-1]
H(E)
H(C-sum)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
18168 KB |
Output is correct |
2 |
Correct |
35 ms |
18204 KB |
Output is correct |
3 |
Correct |
36 ms |
18192 KB |
Output is correct |
4 |
Correct |
36 ms |
18216 KB |
Output is correct |
5 |
Correct |
39 ms |
18148 KB |
Output is correct |
6 |
Correct |
37 ms |
18408 KB |
Output is correct |
7 |
Correct |
797 ms |
40740 KB |
Output is correct |
8 |
Incorrect |
801 ms |
40596 KB |
Output isn't correct |
9 |
Correct |
837 ms |
40184 KB |
Output is correct |
10 |
Correct |
806 ms |
41460 KB |
Output is correct |