| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1336732 | nguyengiabach1201 | Coins (BOI06_coins) | C++20 | 56 ms | 4792 KiB |
// https://oj.uz/problem/view/BOI06_coins
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define el '\n'
#define FNAME "coins"
#define ll long long
#define int long long
#define ld long double
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 7;
const double EPS = 1e-9;
void setup()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen(FNAME ".in", "r"))
{
freopen(FNAME ".in", "r", stdin);
freopen(FNAME ".out", "w", stdout);
}
return;
}
const int N = 5e5 + 5;
int n, k, c[N];
bool d[N];
void solve()
{
cin >> n >> k;
for (int i = 1; i <= n; ++i)
cin >> c[i] >> d[i];
int currentChangeSum = 0;
int newDenominationsCount = 0;
for (int i = 1; i <= n; ++i)
{
if (!d[i])
{
int nextDenom = (i == n) ? k : c[i + 1];
if (currentChangeSum + c[i] < nextDenom)
{
currentChangeSum += c[i];
newDenominationsCount++;
}
}
}
cout << newDenominationsCount << el;
if (newDenominationsCount == 0)
cout << k - 1 << el;
else
cout << k - currentChangeSum << el;
return;
}
signed main()
{
setup();
int t = 1;
bool multiTest = false;
if (multiTest)
cin >> t;
while (t--)
solve();
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
