Submission #726835

# Submission time Handle Problem Language Result Execution time Memory
726835 2023-04-19T12:11:40 Z TimDee Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 680 KB
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define s second
#define pi pair<int,int>

#define vii(a,n) vector<int>a(n);forn(i,n)cin>>a[i];

void solve() {

	int n,m,k; cin>>n>>m>>k;
	if (k-1) exit(1);
	vii(a,n);
	vii(b,m);
	vector<int> dp(1e5,0);
	dp[0]=1;
	int s=0; forn(i,n) s+=a[i];
	int s2=0; forn(i,m) s2+=a[i];
	if (s>s2) {
		cout<<"IMPOSSIBLE"<<endl;
		return;
	}
	for(auto&x:b) {
		for (int i=s; i>=0; --i) {
			dp[i+x]|=dp[i];
		}
	}
	for (int i=s; i<=s2; ++i) {
		if (dp[i]) {
			cout<<i-s<<endl;
			return;
		}
	}
	assert(0);

}

int32_t main() {
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -