이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "jelly.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 510;
int dp[MAXN][MAXN][MAXN];
int calc(int i, int x, int y, int N, vector<int> &a, vector<int> &b)
{
if(x < 0 || y < 0) return -1;
if(dp[i][x][y] != 0) return dp[i][x][y];
if(i > N) return 0;
int op1 = calc(i + 1, x - a[i - 1], y, N, a, b) + 1;
int op2 = calc(i + 1, x, y - b[i - 1], N, a, b) + 1;
int op3 = calc(i + 1, x , y , N, a, b);
dp[i][x][y] = max(max(op1,op2),op3);
// cerr << dp[i][x][y] << " " << i << " " << x << " " << y << "\n";
return dp[i][x][y];
}
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
int N = a.size();
sort(a.begin(),a.end());
int resp = 0;
for(int cur : a)
{
if(x > y && x - cur >= 0) {x-= cur; resp++;}
else if(y - cur >= 0) {y -= cur; resp++;}
}
return resp;
}
컴파일 시 표준 에러 (stderr) 메시지
jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:26:6: warning: unused variable 'N' [-Wunused-variable]
26 | int N = a.size();
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |