# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
898996 |
2024-01-05T10:40:40 Z |
n3rm1n |
Kitchen (BOI19_kitchen) |
C++17 |
|
1000 ms |
468 KB |
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 305;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m, k;
int a[MAXN], b[MAXN];
int total = 0;
void read()
{
cin >> n >> m >> k;
for (int i = 1; i <= n; ++ i)
{
cin >> a[i];
total += a[i];
}
for (int i = 1; i <= m; ++ i)
cin >> b[i];
for (int i = 1; i <= n; ++ i)
{
if(a[i] < k)
{
cout << "Impossible" << endl;
exit(0);
}
}
}
int taken[MAXN];
int p[MAXN], notused[MAXN];
int solve()
{
memset(taken, 0, sizeof(taken));
int left = total, sumup = 0;
int ok = 0;
for (int i = 1; i <= m; ++ i)
{
if(p[i])
{
notused[i] = b[i];
for (int j = 1; j <= n; ++ j)
{
if(taken[j] < k && notused[i] > 0)
{
taken[j] ++;
if(taken[j] == k)ok ++;
notused[i] --;
left --;
}
}
sumup += notused[i];
}
}
if(sumup < left || ok < n)return 1e9;
else
{
return sumup - left;
}
}
int ans = 1e9;
void gen(int pos)
{
if(pos > m)
{
ans = min(ans, solve());
return;
}
p[pos] = 0;
gen(pos+1);
p[pos] = 1;
gen(pos+1);
}
int main()
{
speed();
read();
gen(1);
if(ans == 1e9)cout << "Impossible" << endl;
else cout << ans << endl;
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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
7 ms |
468 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Incorrect |
100 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
7 ms |
468 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Incorrect |
100 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |