Submission #985227

# Submission time Handle Problem Language Result Execution time Memory
985227 2024-05-17T13:17:27 Z OAleksa Kitchen (BOI19_kitchen) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 310;
int n, m, k, a[N], b[N];
int dp[N * N], ndp[N * N];
int dp2[N * N], dp3[N * N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> m >> k;
  	for (int i = 1;i <= n;i++)
  		cin >> a[i];
  	sort(a + 1, a + n + 1);
  	for (int i = 1;i <= m;i++)
  		cin >> b[i];
  	sort(b + 1, b + m + 1);
  	if (m < k || a[1] < k)
  		cout << "Impossible";
  	else {
  		dp[0] = {1, 0};
			for (int i = 1;i <= m;i++) {
				for (int j = 0;j < N * N;j++) {
					if (j < b[i]) {
						dp3[j] = dp2[j];
						ndp[j] = dp[j];
					}
					else {	
						ndp[j] = (dp[j] | dp[j - b[i]]);
						dp3[j] = dp2[j]; 
						int x = min(n, b[i]);
						if ((j >= n * k && j - x < n * k) && ndp[j])
							dp3[j] = 1;
						dp3[j] = (dp3[j] | dp2[j - b[i]]);
					}
				}
				for (int i = 0;i < N * N;i++) {
					dp[i] = ndp[i], ndp[i] = {0, 0};
					dp2[i] = dp3[i], dp3[i] = 0;
				}
			}
			int s = 0, ans = 1e9;
			for (int i = 1;i <= n;i++)
				s += a[i];
			for (int i = N * N - 1;i >= s;i--) {
				if (dp2[i])
					ans = i - s;
			}
			if (ans == 1e9)
				cout << "Impossible\n";
			else
				cout << ans << '\n';
  	}
  }
  return 0; 
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:26:18: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   26 |     dp[0] = {1, 0};
      |                  ^
kitchen.cpp:43:36: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   43 |      dp[i] = ndp[i], ndp[i] = {0, 0};
      |                                    ^