답안 #673242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
673242 2022-12-20T01:53:14 Z Hacv16 Jelly Flavours (IOI20_jelly) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#define fr first
#define sc second

const int MAX = 2005;
const int INF = 0x3f3f3f3f;
 
int a[MAX], b[MAX];
pair<int, int> dp[MAX][MAX];

int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b){
	int n = a.size();
	
	vector<pair<int, int>> aux;

	for(int i = 0; i < n; i++)
		aux.emplace_back(a[i], b[i]);

	sort(aux.begin(), aux.end());

	for(int i = 1; i <= n; i++){
		a[i] = _a[i - 1];
		b[i] = _b[i - 1];
	}	

	dp[0][0] = {0, x};

  	for(int i = 1; i <= y; i++) 
  		dp[0][i] = {-INF, -INF};

  	int ans = 0;

  	for(int i = 1; i <= n; i++){
  		for(int j = 0; j <= y; j++){
  			dp[i][j] = dp[i - 1][j];

  			if(dp[i][j].sc >= a[i]){
  				dp[i][j].fr++, dp[i][j].sc -= a[i];

  			if(j >= b[i]){
  				pair<int, int> t = dp[i - 1][j - b[i]];
  				t.fr++;

  				if(t.fr > dp[i][j].fr || (t.fr == dp[i][j].fr && t.sc > dp[i][j].sc)) 
  					dp[i][j] = t;
  			}

  			ans = max(ans, dp[i][j].fr);
  		}
  	}
 
	return ans;
}

Compilation message

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:18:12: error: request for member 'size' in 'a', which is of non-class type 'int [2005]'
   18 |  int n = a.size();
      |            ^~~~
jelly.cpp:59:1: error: expected '}' at end of input
   59 | }
      | ^
jelly.cpp:17:70: note: to match this '{'
   17 | int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b){
      |                                                                      ^
jelly.cpp:20:25: warning: control reaches end of non-void function [-Wreturn-type]
   20 |  vector<pair<int, int>> aux;
      |                         ^~~