#include <iostream>
#include "jelly.h"
#include <algorithm>
#include <vector>
using namespace std;
const int N = 2e3 + 5;
const int V = 1e4 + 5;;
int dp[N][V];
int find_maximum_unique(int x, int y, vector <int> a, vector <int> b)
{
int i, j, n, m;
n = a.size();
m = b.size();
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (i = 0; i <= max(n, m); i++)
for (j = 0; j <= x; j++)
dp[i][j] = 2e9;
dp[0][0] = 0;
for (i = 1; i <= max(n, m); i++)
{
for (j = 0; j <= x; j++)
{
if (dp[i - 1][j] == 2e9)
continue;
if (i <= n)
dp[i][j + a[i - 1]] = min(dp[i][j], dp[i - 1][j]);
if (i <= m)
dp[i][j] = min(dp[i][j], dp[i - 1][j] + b[i - 1]);
}
}
for (i = max(n, m); 0 <= i; i--)
for (j = x; 0 <= j; j--)
if (dp[i][j] <= y)
return i;
}/*
vector <int> A, B;
int main()
{
int x, y, n, m;
cin >> x >> y >> n >> m;
A.resize(n);
B.resize(m);
for (int i = 0; i < n; i++)
cin >> A[i];
for (int i = 0; i < m; i++)
cin >> B[i];
cout << find_maximum_unique(x, y, A, B);
return 0;
}*/
Compilation message
jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
36 | }/*
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
27668 KB |
1st lines differ - on the 1st token, expected: '689', found: '645' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
158 ms |
76160 KB |
Output is correct |
2 |
Correct |
162 ms |
78016 KB |
Output is correct |
3 |
Correct |
166 ms |
78336 KB |
Output is correct |
4 |
Correct |
121 ms |
74944 KB |
Output is correct |
5 |
Correct |
120 ms |
77780 KB |
Output is correct |
6 |
Correct |
166 ms |
75088 KB |
Output is correct |
7 |
Correct |
162 ms |
77312 KB |
Output is correct |
8 |
Incorrect |
158 ms |
75280 KB |
1st lines differ - on the 1st token, expected: '70', found: '1913' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
158 ms |
77004 KB |
Output is correct |
2 |
Incorrect |
154 ms |
75320 KB |
1st lines differ - on the 1st token, expected: '99', found: '1912' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |