답안 #476401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476401 2021-09-26T10:24:57 Z starplat Jelly Flavours (IOI20_jelly) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
pair<int,int> v[2005],dp[100005];
pair<int,int> cmp(pair<int,int> a,pair<int,int> b)
{
	if (a.f==-1) return b;
	if (a.f<b.f) return b;
	if (a.f==b.f&&a.s>b.s) return b;
	return a;
}
int find_maximum_unique(int x,int y,vector<int>a, vector<int>b)
{
	int n=a.size();
	int ans=0;
	pair<int,int> v[2005],dp[100005];
	for (int i=1;i<=n;i++){
		v[i]={b[i-1],a[i-1]};
	}
	for (int i=1;i<=x;i++) dp[i]={-1,-1};
	dp[1]={0,0};
	sort(v+1,v+1+n);
	for (int i=1;i<=n;i++) swap(v[i].f,v[i].s);
	for (int i=1;i<=n;i++){
		for (int j=x;j>=0;j--){
			if (dp[j].f==-1) continue;
			if (j+v[i].f<=x){
				dp[j+v[i].f]=cmp(dp[j+v[i].f],{dp[j].f+1,dp[j].s});
			}
			if (dp[j].s+v[i].s<=y){
				dp[j]=cmp(dp[j],{dp[j].f+1,dp[j].s+v[i].s});
			}
		}
	}
	for (int i=0;i<=x;i++){
		if (dp[i].f!=-1&&dp[i].s<=x) ans=max(dp[i].f,ans);
	}
	return ans;
}

Compilation message

/usr/bin/ld: /tmp/ccHFlDYy.o: in function `main':
grader.cpp:(.text.startup+0x227): undefined reference to `find_maximum_unique(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status