# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307235 | Rainbowbunny | Coins (BOI06_coins) | C++17 | 94 ms | 9980 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |