This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
#define int long long
using namespace std;
const int sz = 1e3 + 3;
int a[sz], b[sz];
int dp[sz * sz];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m, k;
cin >> n >> m >> k;
int sm = 0;
bool f = false;
for (int i = 1; i <= n; i ++) {
cin >> a[i];
sm += a[i];
if (a[i] < k) {
f = true;
}
}
for (int i = 1; i <= m; i ++) {
cin >> b[i];
}
if (f) {
goto ex;
}
for (int i = 1; i <= m; i ++) {
for (int j = sz * sz - 1; b[i] < j; j --) {
if (dp[j - b[i]]) {
dp[j] = max(dp[j], dp[j - b[i]] + min(b[i], n));
}
}
dp[b[i]] = max(dp[b[i]], min(b[i], n));
}
for (int i = sm; i < sz * sz; i ++) {
if (dp[i] >= n * k) {
cout << i - sm << '\n';
return 0;
}
}
ex:
cout << "IMPOSSIBLE\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |