This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Be Name Khoda
#include<bits/stdc++.h>
#pragma GCC optmize("Ofast,unroll-loops")
#pragma GCC target ("avx2,tune=native")
using namespace std;
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define plll pair<pll, ll>
const ll mxn = 316;
ll n, m, k, q, w;
ll dp[mxn * mxn], mx[mxn * mxn];
vector<ll> a, b;
void input() {
cin >> n >> m >> k;
for(int i = 0; i < n; i++) {
cin >> q;
a.push_back(q);
w += q;
}
for(int i = 0; i < m; i++) {
cin >> q;
b.push_back(q);
}
}
void solve() {
if(m < k) {
cout << "Impossible\n";
return;
}
for(auto u : a) {
if(u < k) {
cout << "Impossible\n";
return;
}
}
dp[0] = 1;
for(auto u : b) {
for(int i = mxn * mxn - 1; i > u - 1; i--) {
if(dp[i - u]) {
dp[i] = 1;
mx[i] = max(mx[i], mx[i - u] + min(n, u));
}
}
}
for(int i = w; i < mxn * mxn; i++) {
if(mx[i] < n * k) continue;
cout << i - w << endl;
return;
}
cout << "Impossible\n";
return;
}
int main() {
ios::sync_with_stdio(false); cin.tie(NULL);
input(), solve();
return 0;
}
Compilation message (stderr)
kitchen.cpp:4: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
4 | #pragma GCC optmize("Ofast,unroll-loops")
|
# | 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... |