제출 #509556

#제출 시각아이디문제언어결과실행 시간메모리
509556kianaRZVKitchen (BOI19_kitchen)C++14
21 / 100
176 ms239060 KiB
#include <bits/stdc++.h> #define F first #define S second #define int long long using namespace std; const int maxn = 3e2 + 5, inf = 1e9 + 9; int n, m, k, ans = inf, sum; int a[maxn], b[maxn], dp[maxn][100005]; bool check; void read_input() { cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; check |= (a[i] < k); } for (int i = 1; i <= m; i++) cin >> b[i]; } void solve() { memset(dp, -1, sizeof dp); dp[0][0] = 0; for (int i = 1; i <= m; i++) for (int j = 0; j < 1e5 + 5; j++) { dp[i][j] = dp[i - 1][j]; if (j - b[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - b[i]] + min(n, b[i])); if (j >= sum && dp[i][j] >= n * k) ans = min(ans, j - sum); } if (ans == inf || check) cout << "Impossible"; else cout << ans; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); read_input(), solve(); 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...