# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169388 |
2019-12-20T07:24:49 Z |
ruler |
Kitchen (BOI19_kitchen) |
C++14 |
|
66 ms |
1152 KB |
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
////////////////////////////////////////////////////////////////////
const int N = 3e2 + 5;
int B[N], DP[2][N * N];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m, k, sum = 0; cin >> n >> m >> k;
if (m < k) die("Impossible");
for (int i = 0; i < n; i++) {
int a; cin >> a;
sum += a;
if (a < k) die("Impossible");
}
for (int i = 1; i <= m; i++) for (int j = 0; j < N * N; j++) DP[i & 1][j] = -INF;
DP[0][0] = 0;
for (int i = 1; i <= m; i++) cin >> B[i];
for (int i = 1; i <= m; i++) for (int j = 0; j < N * N; j++) {
DP[i & 1][j] = DP[(i - 1) & 1][j];
if (j >= B[i]) DP[i & 1][j] = max(DP[i & 1][j], DP[(i - 1) & 1][j - B[i]] + min(B[i], n));
}
for (int i = 0; i + sum < N * N; i++) if (DP[m & 1][i + sum] >= n * k) die(i);
cout << "Impossible" << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1016 KB |
Output is correct |
2 |
Correct |
3 ms |
1016 KB |
Output is correct |
3 |
Correct |
3 ms |
1016 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
3 ms |
1144 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1016 KB |
Output is correct |
2 |
Correct |
3 ms |
1016 KB |
Output is correct |
3 |
Correct |
3 ms |
1016 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
3 ms |
1144 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
1016 KB |
Output is correct |
9 |
Correct |
6 ms |
1144 KB |
Output is correct |
10 |
Correct |
6 ms |
1020 KB |
Output is correct |
11 |
Correct |
6 ms |
1144 KB |
Output is correct |
12 |
Correct |
5 ms |
1144 KB |
Output is correct |
13 |
Correct |
5 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
1152 KB |
Output is correct |
2 |
Correct |
51 ms |
1144 KB |
Output is correct |
3 |
Correct |
66 ms |
1144 KB |
Output is correct |
4 |
Correct |
66 ms |
1144 KB |
Output is correct |
5 |
Correct |
64 ms |
1016 KB |
Output is correct |
6 |
Correct |
47 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1016 KB |
Output is correct |
2 |
Correct |
11 ms |
1148 KB |
Output is correct |
3 |
Correct |
11 ms |
1144 KB |
Output is correct |
4 |
Correct |
11 ms |
1016 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1016 KB |
Output is correct |
2 |
Correct |
3 ms |
1016 KB |
Output is correct |
3 |
Correct |
3 ms |
1016 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
3 ms |
1144 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
1016 KB |
Output is correct |
9 |
Correct |
6 ms |
1144 KB |
Output is correct |
10 |
Correct |
6 ms |
1020 KB |
Output is correct |
11 |
Correct |
6 ms |
1144 KB |
Output is correct |
12 |
Correct |
5 ms |
1144 KB |
Output is correct |
13 |
Correct |
5 ms |
1016 KB |
Output is correct |
14 |
Correct |
58 ms |
1152 KB |
Output is correct |
15 |
Correct |
51 ms |
1144 KB |
Output is correct |
16 |
Correct |
66 ms |
1144 KB |
Output is correct |
17 |
Correct |
66 ms |
1144 KB |
Output is correct |
18 |
Correct |
64 ms |
1016 KB |
Output is correct |
19 |
Correct |
47 ms |
1144 KB |
Output is correct |
20 |
Correct |
11 ms |
1016 KB |
Output is correct |
21 |
Correct |
11 ms |
1148 KB |
Output is correct |
22 |
Correct |
11 ms |
1144 KB |
Output is correct |
23 |
Correct |
11 ms |
1016 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
48 ms |
1140 KB |
Output is correct |
26 |
Correct |
55 ms |
1016 KB |
Output is correct |
27 |
Correct |
36 ms |
1016 KB |
Output is correct |
28 |
Correct |
54 ms |
1140 KB |
Output is correct |
29 |
Correct |
55 ms |
1020 KB |
Output is correct |
30 |
Correct |
66 ms |
1148 KB |
Output is correct |