#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
const long long INF = 1e15;
const int N = 3e5 + 2;
//const int mod = 1e9 + 7;//998244353;//1e9 + 7;//786433;
const double Pi = acos(-1);
void Fastio()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n, k;
int cnt, ans;
int a[500005], b[500005];
signed main()
{
Fastio();
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
}
a[n + 1] = k;
for(int i = 1; i <= n; i++)
{
if(b[i] == 0 and ans + a[i] < a[i + 1])
{
ans += a[i];
cnt++;
}
}
cout << cnt << '\n' << min(k - ans, k - 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
89 ms |
9976 KB |
Output is correct |
8 |
Correct |
90 ms |
9980 KB |
Output is correct |
9 |
Correct |
93 ms |
9976 KB |
Output is correct |
10 |
Correct |
94 ms |
9848 KB |
Output is correct |