#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 << (last == 0 ? K - 1 : (K - last)) << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
255 ms |
4204 KB |
Output is correct |
8 |
Correct |
259 ms |
4196 KB |
Output is correct |
9 |
Correct |
247 ms |
4208 KB |
Output is correct |
10 |
Correct |
252 ms |
4196 KB |
Output is correct |