# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1104111 | Kirill22 | Coins (BOI06_coins) | C++17 | 91 ms | 10056 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<pair<int, int>> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
vector<int> dp(50, k);
dp[0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 50; j++) {
if (dp[j] >= a[i].first) {
dp[j] = k;
}
}
if (a[i].second == 1) {
//
} else {
for (int j = 49; j; j--) {
if (dp[j - 1] != k && dp[j - 1] + a[i].first < k) {
dp[j] = min(dp[j], dp[j - 1] + a[i].first);
}
}
}
}
pair<int, int> answer = {0, -1};
for (int j = 1; j < 50; j++) {
if (dp[j] != k) {
answer = max(answer, pair{j, -dp[j]});
}
}
cout << answer.first << '\n' << k + answer.second << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |