#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
const int MAXM = 1e4 + 10;
const int INF = 0x3f3f3f3f;
int dp[MAXN][MAXM];
int dp2[MAXN][MAXM];
int n, a[MAXN], b[MAXN];
vector<pair<int, int> > buga;
int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b) {
n = _a.size();
if (x > y) {
swap(x, y);
swap(_a, _b);
}
for (int i = 0; i < n; i++)
buga.emplace_back(_a[i], _b[i]);
sort(buga.begin(), buga.end());
for (int i = 1; i <= n; i++) {
a[i] = buga[i - 1].first;
b[i] = buga[i - 1].second;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= x; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= a[i])
dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]] + 1);
}
}
for(int i = n, j = x; i >= 1; i--)
{
if (j >= a[i] && dp[i][j] == dp[i-1][j - a[i]] + 1) {
j -= a[i]; b[i] = INF;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= y; j++) {
dp2[i][j] = dp2[i - 1][j];
if (j >= b[i])
dp2[i][j] = max(dp2[i][j], dp2[i - 1][j - b[i]] + 1);
}
}
return (dp[n][x] + dp2[n][y] + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
1st lines differ - on the 1st token, expected: '8', found: '9' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
1st lines differ - on the 1st token, expected: '8', found: '9' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
29232 KB |
1st lines differ - on the 1st token, expected: '689', found: '690' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
57 ms |
94352 KB |
1st lines differ - on the 1st token, expected: '62', found: '63' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
61 ms |
93312 KB |
1st lines differ - on the 1st token, expected: '154', found: '155' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
1st lines differ - on the 1st token, expected: '8', found: '9' |
4 |
Halted |
0 ms |
0 KB |
- |