제출 #131100

#제출 시각아이디문제언어결과실행 시간메모리
131100IOrtroiiiKitchen (BOI19_kitchen)C++14
21 / 100
28 ms760 KiB
#include <bits/stdc++.h> using namespace std; const int N = 305; const int M = N * N; int a[N]; int b[N]; int f[M]; int main() { ios_base::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= m; ++i) { cin >> b[i]; } if (*min_element(a + 1, a + n + 1) < k) { cout << "Impossible\n"; return 0; } memset(f, -69, sizeof f); f[0] = 0; for (int i = 1; i <= m; ++i) { for (int j = M - 1; j >= b[i]; --j) { f[j] = max(f[j], f[j - b[i]] + min(b[i], n)); } } int sum = accumulate(a + 1, a + m + 1, 0); for (int i = sum; i < M; ++i) { if (f[i] >= n * k) { cout << i - sum << "\n"; return 0; } } cout << "Impossible\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...