답안 #984385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984385 2024-05-16T15:14:06 Z OAleksa Kitchen (BOI19_kitchen) C++14
20 / 100
27 ms 1216 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 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];
  	if (m < k || a[1] < k)
  		cout << "Impossible";
  	else {
  		dp[0] = 1;
			for (int i = 1;i <= m;i++) {
				for (int j = 0;j < N * N;j++) {
					if (j < b[i])
						ndp[j] = dp[j];
					else
						ndp[j] = (dp[j - b[i]] | dp[j]);
				}
				for (int i = 0;i < N * N;i++)
					dp[i] = ndp[i], ndp[i] = 0;
			}
			int s = 0, ans = 1e9;
			for (int i = 1;i <= n;i++)
				s += a[i];
			for (int i = N * N;i >= s;i--) {
				if (dp[i])
					ans = i - s;
			}
			if (ans == 1e9)
				cout << "Impossible\n";
			else
				cout << ans << '\n';
  	}
  }
  return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Incorrect 1 ms 1112 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Incorrect 1 ms 1112 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1112 KB Output is correct
2 Correct 20 ms 1112 KB Output is correct
3 Correct 26 ms 1192 KB Output is correct
4 Correct 27 ms 1216 KB Output is correct
5 Correct 25 ms 1116 KB Output is correct
6 Correct 19 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Incorrect 1 ms 1112 KB Output isn't correct
5 Halted 0 ms 0 KB -