# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1099374 |
2024-10-11T08:51:25 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
73 ms |
100504 KB |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int MaxN = 3e2 + 5;
int n, m, k;
int a[MaxN];
int b[MaxN];
void Inp()
{
cin >> n >> m >> k;
for (int x = 1; x <= n; x++)
{
cin >> a[x];
}
for (int x = 1; x <= m; x++)
{
cin >> b[x];
}
}
int F[MaxN][MaxN * MaxN + 5];
void Exc()
{
int suma = 0, sumb = 0;
for (int x = 1; x <= n; x++)
{
suma += a[x];
if (a[x] < k || m < k)
{
cout << "Impossible";
return;
}
}
for (int x = 1; x <= m; x++)
{
sumb += b[x];
}
for (int x = 0; x <= m; x++)
{
for (int y = 0; y <= sumb; y++)
{
F[x][y] = -1;
}
}
F[0][0] = 0;
for (int x = 1; x <= m; x++)
{
for (int y = 0; y < b[x]; y++)
{
if (F[x - 1][y] != -1)
{
F[x][y] = F[x - 1][y];
}
}
for (int y = b[x]; y <= sumb; y++)
{
if (F[x - 1][y] != -1)
{
F[x][y] = F[x - 1][y];
}
if (F[x - 1][y - b[x]] != -1)
{
F[x][y] = max(F[x][y], F[x - 1][y - b[x]] + min(b[x], n));
}
}
}
for (int x = suma; x <= sumb; x++)
{
if (F[m][x] >= n * k)
{
cout << x - suma;
return;
}
}
cout << "Impossible";
}
int main()
{
//freopen("G.INP", "r", stdin);
//freopen("G.OUT", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int test = 1;
//cin >> test;
for (int x = 1; x <= test; x++)
{
Inp();
Exc();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
68952 KB |
Output is correct |
2 |
Correct |
39 ms |
51804 KB |
Output is correct |
3 |
Correct |
42 ms |
58204 KB |
Output is correct |
4 |
Correct |
73 ms |
98644 KB |
Output is correct |
5 |
Correct |
71 ms |
98904 KB |
Output is correct |
6 |
Correct |
30 ms |
42328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
45 ms |
68952 KB |
Output is correct |
15 |
Correct |
39 ms |
51804 KB |
Output is correct |
16 |
Correct |
42 ms |
58204 KB |
Output is correct |
17 |
Correct |
73 ms |
98644 KB |
Output is correct |
18 |
Correct |
71 ms |
98904 KB |
Output is correct |
19 |
Correct |
30 ms |
42328 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
39 ms |
50524 KB |
Output is correct |
26 |
Correct |
45 ms |
62552 KB |
Output is correct |
27 |
Correct |
14 ms |
19032 KB |
Output is correct |
28 |
Correct |
38 ms |
51548 KB |
Output is correct |
29 |
Correct |
44 ms |
70328 KB |
Output is correct |
30 |
Correct |
63 ms |
100504 KB |
Output is correct |