#include "jelly.h"
#include <vector>
#include <algorithm>
using namespace std;
const int N = 2e3 + 5, M = 1e4 + 5;
using ii = pair<int, int>;
ii a[N], dp[N][M];
ii best(ii& u, ii& v) {
if (u.first == v.first) return u.second < v.second ? u : v;
return u.first > v.first ? u : v;
}
int n, X, Y;
int find_maximum_unique(int _x, int _y, std::vector<int> _a, std::vector<int> _b) {
n = _a.size(), X = _x, Y = _y;
for (int i = 1; i <= n; ++i)
a[i] = {_a[i-1], _b[i-1]};
sort(a + 1, a + n + 1, [&](ii& u, ii& v) {
return u.second < v.second;
});
for (int x = 0; x <= X; ++x)
dp[0][x] = {0, 0};
for (int i = 1; i <= n; ++i) for (int x = 0; x <= X; ++x) {
dp[i][x] = dp[i-1][x];
if (x >= a[i].first) {
auto p = dp[i-1][x-a[i].first]; p.first++;
dp[i][x] = best(dp[i][x], p);
}
if (dp[i-1][x].second + a[i].second <= Y) {
auto p = dp[i-1][x]; p.first++; p.second += a[i].second;
dp[i][x] = best(dp[i][x], p);
}
}
return n;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '8', found: '9' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '8', found: '9' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
34276 KB |
1st lines differ - on the 1st token, expected: '689', found: '1949' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
88 ms |
149836 KB |
1st lines differ - on the 1st token, expected: '62', found: '1936' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
94 ms |
149672 KB |
1st lines differ - on the 1st token, expected: '154', found: '1959' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
1st lines differ - on the 1st token, expected: '8', found: '9' |
2 |
Halted |
0 ms |
0 KB |
- |