# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
509556 |
2022-01-14T06:43:14 Z |
kianaRZV |
Kitchen (BOI19_kitchen) |
C++14 |
|
176 ms |
239060 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
121 ms |
238936 KB |
Output is correct |
2 |
Correct |
103 ms |
238984 KB |
Output is correct |
3 |
Correct |
110 ms |
238940 KB |
Output is correct |
4 |
Correct |
116 ms |
239024 KB |
Output is correct |
5 |
Correct |
101 ms |
238960 KB |
Output is correct |
6 |
Correct |
97 ms |
238960 KB |
Output is correct |
7 |
Correct |
107 ms |
238964 KB |
Output is correct |
8 |
Incorrect |
121 ms |
238948 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
238936 KB |
Output is correct |
2 |
Correct |
103 ms |
238984 KB |
Output is correct |
3 |
Correct |
110 ms |
238940 KB |
Output is correct |
4 |
Correct |
116 ms |
239024 KB |
Output is correct |
5 |
Correct |
101 ms |
238960 KB |
Output is correct |
6 |
Correct |
97 ms |
238960 KB |
Output is correct |
7 |
Correct |
107 ms |
238964 KB |
Output is correct |
8 |
Incorrect |
121 ms |
238948 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
176 ms |
239060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
239000 KB |
Output is correct |
2 |
Correct |
112 ms |
238992 KB |
Output is correct |
3 |
Correct |
133 ms |
239052 KB |
Output is correct |
4 |
Correct |
115 ms |
239060 KB |
Output is correct |
5 |
Correct |
120 ms |
239020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
238936 KB |
Output is correct |
2 |
Correct |
103 ms |
238984 KB |
Output is correct |
3 |
Correct |
110 ms |
238940 KB |
Output is correct |
4 |
Correct |
116 ms |
239024 KB |
Output is correct |
5 |
Correct |
101 ms |
238960 KB |
Output is correct |
6 |
Correct |
97 ms |
238960 KB |
Output is correct |
7 |
Correct |
107 ms |
238964 KB |
Output is correct |
8 |
Incorrect |
121 ms |
238948 KB |
Output isn't correct |