# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878939 | Tien_Noob | Kitchen (BOI19_kitchen) | C++17 | 20 ms | 816 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
using namespace std;
const int N = 3e2;
int dp[N * N + 1];
int n, m, k, a[N + 1], b[N + 1], sum;
void read()
{
cin >> n >> m >> k;
for (int i = 1; i <= n; ++ i)
{
cin >> a[i];
if (a[i] < k)
{
cout << "Impossible";
exit(0);
}
sum += a[i];
}
for (int j = 1; j <= m; ++ j)
{
cin >> b[j];
}
}
void solve()
{
memset(dp, -0x3f, sizeof(dp));
dp[0] = 0;
for (int j = 1; j <= m; ++ j)
{
for (int i = N * N - b[j]; i >= 0; -- i)
{
dp[i + b[j]] = max(dp[i + b[j]], dp[i] + min(n, b[j]));
}
}
for (int i = sum; i <= N * N; ++ i)
{
if (dp[i] >= n * k)
{
cout << i - sum;
return ;
}
}
cout << "Impossible";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
//freopen(TASK".OUT", "w", stdout);
}
int t = 1;
bool typetest = false;
if (typetest)
{
cin >> t;
}
for (int __ = 1; __ <= t; ++ __)
{
//cout << "Case " << __ << ": ";
read();
solve();
}
}
Compilation message (stderr)
# | 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... |