# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
572849 | denniskim | Coins (BOI06_coins) | C++17 | 106 ms | 9336 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>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
ll n, k;
pair<ll, ll> a[500010];
ll ans1, ans2;
int main(void)
{
scanf("%lld %lld", &n, &k);
for(ll i = 1 ; i <= n ; i++)
scanf("%lld %lld", &a[i].fi, &a[i].se);
for(ll i = 1 ; i <= n ; i++)
{
if(a[i].se)
continue;
if(ans1 + a[i].fi < min(a[i + 1].fi, k + 1))
{
ans1 += a[i].fi;
ans2++;
}
}
printf("%lld\n%lld", ans2, k - ans1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |