# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
552010 |
2022-04-22T07:51:50 Z |
ollel |
Kitchen (BOI19_kitchen) |
C++14 |
|
254 ms |
13064 KB |
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; i++)
typedef vector<int> vi;
typedef vector<vi> vvi;
int n, m, k;
vi a, b;
int main() {
cin >> n >> m >> k;
a.resize(n);
b.resize(m);
rep(i,0,n) cin >> a[i];
rep(i,0,m) cin >> b[i];
rep(i,0,n) if (a[i] < k) {
cout << "Impossible\n";
exit(0);
}
// dp[i] = num
// dp[i] = maximum sum2 with sum1 = i?
const int maxs = 3300*330;
vvi dp(2, vi(maxs, -1));
dp[0][0] = 0; dp[1][0] = 0;
rep(i,0,m) {
int sum1 = b[i];
int sum2 = min(b[i], n);
int i1 = i&1;
rep(j,0,maxs - sum1) {
if (dp[i1][j] == -1) continue;
dp[i1^1][j + sum1] = max(dp[i1^1][j + sum1], dp[i1][j] + sum2);
}
}
int minimi = n * k;
int start = 0;
rep(i,0,n) start += a[i];
rep(i, start, maxs) {
if (dp[0][i] >= minimi || dp[1][i] >= minimi) {
cout << (i - start) << endl;
exit(0);
}
}
cout << "Impossible" << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
13012 KB |
Output is correct |
2 |
Correct |
10 ms |
12984 KB |
Output is correct |
3 |
Correct |
8 ms |
13012 KB |
Output is correct |
4 |
Correct |
8 ms |
13012 KB |
Output is correct |
5 |
Correct |
8 ms |
13012 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
9 ms |
13012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
13012 KB |
Output is correct |
2 |
Correct |
10 ms |
12984 KB |
Output is correct |
3 |
Correct |
8 ms |
13012 KB |
Output is correct |
4 |
Correct |
8 ms |
13012 KB |
Output is correct |
5 |
Correct |
8 ms |
13012 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
9 ms |
13012 KB |
Output is correct |
9 |
Correct |
19 ms |
13012 KB |
Output is correct |
10 |
Correct |
22 ms |
13008 KB |
Output is correct |
11 |
Correct |
19 ms |
13012 KB |
Output is correct |
12 |
Correct |
19 ms |
13012 KB |
Output is correct |
13 |
Incorrect |
20 ms |
13012 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
254 ms |
13012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
13012 KB |
Output is correct |
2 |
Incorrect |
39 ms |
13064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
13012 KB |
Output is correct |
2 |
Correct |
10 ms |
12984 KB |
Output is correct |
3 |
Correct |
8 ms |
13012 KB |
Output is correct |
4 |
Correct |
8 ms |
13012 KB |
Output is correct |
5 |
Correct |
8 ms |
13012 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
9 ms |
13012 KB |
Output is correct |
9 |
Correct |
19 ms |
13012 KB |
Output is correct |
10 |
Correct |
22 ms |
13008 KB |
Output is correct |
11 |
Correct |
19 ms |
13012 KB |
Output is correct |
12 |
Correct |
19 ms |
13012 KB |
Output is correct |
13 |
Incorrect |
20 ms |
13012 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |