# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
204000 |
2020-02-23T14:11:35 Z |
mdn2002 |
Kitchen (BOI19_kitchen) |
C++14 |
|
37 ms |
716 KB |
#include<bits/stdc++.h>
using namespace std;
int n,m,k,a[305],b[305],dp[90005],sum=0;
int main()
{
cin>>n>>m>>k;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
if(a[i]<k)
{
cout<<"Impossible";
return 0;
}
}
for(int i=0;i<m;i++)cin>>b[i];
memset(dp,-1,sizeof dp);
dp[0]=0;
for(int i=0;i<m;i++)
{
for(int j=90005-b[i];j>=0;j--)
{
if(dp[j]!=-1)dp[j+b[i]]=max(dp[j]+min(n,b[i]),dp[j+b[i]]);
}
}
int mn=n*k;
for(int i=sum;i<=90005;i++)
{
if(dp[i]>=mn)
{
cout<<i-sum;
return 0;
}
}
cout<<"Impossible"<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
6 ms |
632 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
6 ms |
632 KB |
Output is correct |
12 |
Correct |
6 ms |
632 KB |
Output is correct |
13 |
Correct |
6 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
632 KB |
Output is correct |
2 |
Correct |
23 ms |
632 KB |
Output is correct |
3 |
Correct |
32 ms |
632 KB |
Output is correct |
4 |
Correct |
37 ms |
632 KB |
Output is correct |
5 |
Correct |
33 ms |
716 KB |
Output is correct |
6 |
Correct |
23 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
632 KB |
Output is correct |
2 |
Correct |
8 ms |
632 KB |
Output is correct |
3 |
Correct |
8 ms |
632 KB |
Output is correct |
4 |
Correct |
8 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
6 ms |
632 KB |
Output is correct |
10 |
Correct |
6 ms |
632 KB |
Output is correct |
11 |
Correct |
6 ms |
632 KB |
Output is correct |
12 |
Correct |
6 ms |
632 KB |
Output is correct |
13 |
Correct |
6 ms |
632 KB |
Output is correct |
14 |
Correct |
28 ms |
632 KB |
Output is correct |
15 |
Correct |
23 ms |
632 KB |
Output is correct |
16 |
Correct |
32 ms |
632 KB |
Output is correct |
17 |
Correct |
37 ms |
632 KB |
Output is correct |
18 |
Correct |
33 ms |
716 KB |
Output is correct |
19 |
Correct |
23 ms |
632 KB |
Output is correct |
20 |
Correct |
8 ms |
632 KB |
Output is correct |
21 |
Correct |
8 ms |
632 KB |
Output is correct |
22 |
Correct |
8 ms |
632 KB |
Output is correct |
23 |
Correct |
8 ms |
632 KB |
Output is correct |
24 |
Correct |
5 ms |
256 KB |
Output is correct |
25 |
Correct |
21 ms |
632 KB |
Output is correct |
26 |
Correct |
25 ms |
632 KB |
Output is correct |
27 |
Correct |
19 ms |
636 KB |
Output is correct |
28 |
Correct |
27 ms |
632 KB |
Output is correct |
29 |
Correct |
29 ms |
632 KB |
Output is correct |
30 |
Correct |
35 ms |
632 KB |
Output is correct |