답안 #370726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370726 2021-02-24T14:09:09 Z MilosMilutinovic Jelly Flavours (IOI20_jelly) C++14
컴파일 오류
0 ms 0 KB
#include "jelly.h"
#include <bits/stdc++.h>

using namespace std;

void ckmax(int& a, int b) {a = max(a, b);}
void ckmin(int& a, int b) {a = min(a, b);}

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
	int n = (int) a.size();
	if (max(x, y) <= 500) {
		vector<vector<vector<int>>> dp(n, vector<vector<int>>(x + 1, vector<int>(y + 1)));
		dp[0][x][y] = 0;
		if (x >= a[0]) dp[0][x - a[0]][y] = 1;
		if (y >= b[0]) dp[0][x][y - b[0]] = 1;
		for (int i = 1; i < n; i++) {
			ckmax(dp[i][x - a[i]][y], 1);
			ckmax(dp[i][x][y - b[i]], 1);
			for (int j = 0; j < i; j++) {
				for (int xx = 0; xx <= x; xx++) {
					for (int yy = 0; yy <= y; yy++) {
						if (xx + a[i] <= x) {
							ckmax(dp[i][xx][yy], dp[j][xx + a[i]][yy] + 1);
						}
						if (yy + b[i] <= x) {
							ckmax(dp[i][xx][yy], dp[j][xx][yy + b[j]] + 1);
						}
						ckmax(dp[i][xx][yy], dp[j][xx][yy]);
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int xx = 0; xx <= x; xx++) {
				for (int yy = 0; yy <= y; yy++) {
					ans = max(ans, dp[i][xx][yy]);
				}
			}
		}
		return ans;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int x, y;
	cin >> x >> y;
	vector<int> a(x), b(y);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; 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:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
/tmp/ccyI0A3c.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc4SfCAy.o:jelly.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status