답안 #849198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849198 2023-09-14T09:07:08 Z vjudge1 Art Collections (BOI22_art) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;
int dp[2*N];
int32_t main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n, l;
	cin >> n >> l;
	vector<int> a(2*n + 1);
	vector<int> b;
	for (int i=-n;i<=n;i++){
		cin >> a[i+n];
		int frq = a[i+n];
		for (int j=0;j<frq;j++) b.pb(i);
	}
	dp[N] = 1;// 0
	for (int i=0;i<sz(b);i++){
		if (b[i] >= 0){
			for (int k=2*N;k>=b[i];k--){
				if (dp[k-b[i]]) dp[k] = max(dp[k], dp[k-b[i]]+1);
			}
		}
		else {
			b[i] = -b[i];
			for (int k=0;k+b[i]<2*N;k++){
				if (dp[k+b[i]]) dp[k] = max(dp[k], dp[k+b[i]]+1);
			}
		}
	}
	if (dp[N+l]) cout << dp[N+l]-1 << endl;
	else cout << "impossible\n";
}

Compilation message

interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccfe27vJ.o: in function `main':
interface.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccR0csvL.o:art.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccfe27vJ.o: in function `main':
interface.cpp:(.text.startup+0x16): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status