# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
567217 |
2022-05-23T09:26:25 Z |
Rifal |
Kitchen (BOI19_kitchen) |
C++14 |
|
1000 ms |
215244 KB |
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
const int M = 9e4 + 5;
const int N = 300 + 5;
pair<bool,int> dp[M][N] = {};
void add(int x)
{
for(int i = M-1; i >= x; i--)
{
for(int j = 1; j < N; j++)
{
if(dp[i-x][j-1].first)
{
dp[i][j].first = 1;
dp[i][j].second = min(dp[i][j].second,x);
}
}
}
}
int main()
{
int n, m, k;
cin >> n >> m >> k;
int meal[n], chef[m];
dp[0][0].first = 1;
for(int i = 0; i < M; i++)
{
for(int j = 0; j < N; j++)
{
dp[i][j].second = INF;
}
}
long long sum = 0;
bool ok = true;
for(int i = 0; i < n; i++)
{
cin >> meal[i];
if(meal[i] < k)
ok = false;
sum += meal[i];
}
for(int i = 0; i < m; i++)
{
cin >> chef[i];
add(chef[i]);
}
if(m < k || ok == false)
{
cout << "Impossible";
return 0;
}
for(int i = sum; i < M; i++)
{
for(int j = k; j < N; j++)
{
if(dp[i][j].first == 1 && dp[i][j].second >= k && dp[i][j].second != INF)
{
cout << i-sum;
return 0;
}
}
}
cout << "Impossible";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
231 ms |
215244 KB |
Output is correct |
2 |
Correct |
201 ms |
215052 KB |
Output is correct |
3 |
Correct |
224 ms |
215156 KB |
Output is correct |
4 |
Correct |
225 ms |
215084 KB |
Output is correct |
5 |
Correct |
206 ms |
215192 KB |
Output is correct |
6 |
Correct |
236 ms |
215164 KB |
Output is correct |
7 |
Correct |
207 ms |
215168 KB |
Output is correct |
8 |
Correct |
246 ms |
215164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
231 ms |
215244 KB |
Output is correct |
2 |
Correct |
201 ms |
215052 KB |
Output is correct |
3 |
Correct |
224 ms |
215156 KB |
Output is correct |
4 |
Correct |
225 ms |
215084 KB |
Output is correct |
5 |
Correct |
206 ms |
215192 KB |
Output is correct |
6 |
Correct |
236 ms |
215164 KB |
Output is correct |
7 |
Correct |
207 ms |
215168 KB |
Output is correct |
8 |
Correct |
246 ms |
215164 KB |
Output is correct |
9 |
Correct |
916 ms |
215144 KB |
Output is correct |
10 |
Correct |
777 ms |
215164 KB |
Output is correct |
11 |
Incorrect |
713 ms |
215184 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1097 ms |
215056 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
215092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
231 ms |
215244 KB |
Output is correct |
2 |
Correct |
201 ms |
215052 KB |
Output is correct |
3 |
Correct |
224 ms |
215156 KB |
Output is correct |
4 |
Correct |
225 ms |
215084 KB |
Output is correct |
5 |
Correct |
206 ms |
215192 KB |
Output is correct |
6 |
Correct |
236 ms |
215164 KB |
Output is correct |
7 |
Correct |
207 ms |
215168 KB |
Output is correct |
8 |
Correct |
246 ms |
215164 KB |
Output is correct |
9 |
Correct |
916 ms |
215144 KB |
Output is correct |
10 |
Correct |
777 ms |
215164 KB |
Output is correct |
11 |
Incorrect |
713 ms |
215184 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |