#include <bits/stdc++.h>
using namespace std;
#define di pair<int, int>
#define vd vector<di>
int main () {
int N, K;
cin >> N >> K;
vd res(N + 1);
for (int i = 0; i < N; i ++) {
int x, v;
cin >> x >> v;
res[i] = { x, 1 - v };
}
res[N] = { K, 0 };
int last = 0;
int mval = 0;
for (int i = 0; i < N; i ++) {
if (res[i].second == 0) continue ;
int dx = res[i + 1].first - res[i].first;
if (last >= dx) continue ;
last += res[i].first;
mval += 1;
}
cout << mval << endl;
cout << (K - last) << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
282 ms |
10088 KB |
Output is correct |
8 |
Incorrect |
277 ms |
9964 KB |
Output isn't correct |
9 |
Correct |
272 ms |
9952 KB |
Output is correct |
10 |
Correct |
302 ms |
9780 KB |
Output is correct |