# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
320455 |
2020-11-08T19:35:14 Z |
Marlov |
Kitchen (BOI19_kitchen) |
C++14 |
|
97 ms |
111480 KB |
/*
Code by @marlov
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
#define maxV 305
#define INF 1000000000
int N,M,K;
int A[maxV];
int B[maxV];
int dp[maxV][maxV*maxV];
int mina=maxV;
int At=0;
int Bt=0;
int result=INF;
//dp values and value after chef i works on it
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N>>M>>K;
for(int i=0;i<maxV;i++){
fill(dp[i],dp[i]+(maxV*maxV),-INF);
}
for(int i=1;i<=N;i++){
cin>>A[i];
mina=min(mina,A[i]);
At+=A[i];
}
if(mina<K){
cout<<"Impossible"<<'\n';
return 0;
}
for(int i=1;i<=M;i++){
cin>>B[i];
Bt+=B[i];
}
dp[0][0]=0;
for(int i=1;i<=M;i++){
for(int j=0;j<B[i];j++){
dp[i][j]=dp[i-1][j];
}
for(int j=B[i];j<=Bt;j++){
dp[i][j]=max(dp[i-1][j],dp[i-1][j-B[i]]+min(B[i],N));
//cout<<i<<" "<<j<<" : "<<dp[i][j]<<'\n';
}
}
for(int i=At;i<=Bt;i++){
if(dp[M][i]>=N*K){
result=min(result,i-At);
}
}
if(result==INF){
cout<<"Impossible"<<'\n';
return 0;
}else{
cout<<result<<'\n';
}
return 0;
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1,n=0?)
* do smth instead of nothing and stay organized
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
111336 KB |
Output is correct |
2 |
Correct |
69 ms |
111460 KB |
Output is correct |
3 |
Correct |
80 ms |
111332 KB |
Output is correct |
4 |
Correct |
72 ms |
111332 KB |
Output is correct |
5 |
Correct |
65 ms |
111460 KB |
Output is correct |
6 |
Correct |
65 ms |
111332 KB |
Output is correct |
7 |
Correct |
75 ms |
111332 KB |
Output is correct |
8 |
Correct |
65 ms |
111332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
111336 KB |
Output is correct |
2 |
Correct |
69 ms |
111460 KB |
Output is correct |
3 |
Correct |
80 ms |
111332 KB |
Output is correct |
4 |
Correct |
72 ms |
111332 KB |
Output is correct |
5 |
Correct |
65 ms |
111460 KB |
Output is correct |
6 |
Correct |
65 ms |
111332 KB |
Output is correct |
7 |
Correct |
75 ms |
111332 KB |
Output is correct |
8 |
Correct |
65 ms |
111332 KB |
Output is correct |
9 |
Correct |
65 ms |
111332 KB |
Output is correct |
10 |
Correct |
66 ms |
111332 KB |
Output is correct |
11 |
Correct |
78 ms |
111376 KB |
Output is correct |
12 |
Correct |
74 ms |
111332 KB |
Output is correct |
13 |
Correct |
65 ms |
111328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
111332 KB |
Output is correct |
2 |
Correct |
79 ms |
111460 KB |
Output is correct |
3 |
Correct |
93 ms |
111480 KB |
Output is correct |
4 |
Correct |
97 ms |
111380 KB |
Output is correct |
5 |
Correct |
94 ms |
111384 KB |
Output is correct |
6 |
Correct |
78 ms |
111332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
111332 KB |
Output is correct |
2 |
Correct |
67 ms |
111332 KB |
Output is correct |
3 |
Correct |
80 ms |
111372 KB |
Output is correct |
4 |
Correct |
65 ms |
111332 KB |
Output is correct |
5 |
Correct |
65 ms |
111332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
111336 KB |
Output is correct |
2 |
Correct |
69 ms |
111460 KB |
Output is correct |
3 |
Correct |
80 ms |
111332 KB |
Output is correct |
4 |
Correct |
72 ms |
111332 KB |
Output is correct |
5 |
Correct |
65 ms |
111460 KB |
Output is correct |
6 |
Correct |
65 ms |
111332 KB |
Output is correct |
7 |
Correct |
75 ms |
111332 KB |
Output is correct |
8 |
Correct |
65 ms |
111332 KB |
Output is correct |
9 |
Correct |
65 ms |
111332 KB |
Output is correct |
10 |
Correct |
66 ms |
111332 KB |
Output is correct |
11 |
Correct |
78 ms |
111376 KB |
Output is correct |
12 |
Correct |
74 ms |
111332 KB |
Output is correct |
13 |
Correct |
65 ms |
111328 KB |
Output is correct |
14 |
Correct |
85 ms |
111332 KB |
Output is correct |
15 |
Correct |
79 ms |
111460 KB |
Output is correct |
16 |
Correct |
93 ms |
111480 KB |
Output is correct |
17 |
Correct |
97 ms |
111380 KB |
Output is correct |
18 |
Correct |
94 ms |
111384 KB |
Output is correct |
19 |
Correct |
78 ms |
111332 KB |
Output is correct |
20 |
Correct |
67 ms |
111332 KB |
Output is correct |
21 |
Correct |
67 ms |
111332 KB |
Output is correct |
22 |
Correct |
80 ms |
111372 KB |
Output is correct |
23 |
Correct |
65 ms |
111332 KB |
Output is correct |
24 |
Correct |
65 ms |
111332 KB |
Output is correct |
25 |
Correct |
79 ms |
111332 KB |
Output is correct |
26 |
Correct |
87 ms |
111332 KB |
Output is correct |
27 |
Correct |
71 ms |
111332 KB |
Output is correct |
28 |
Correct |
80 ms |
111332 KB |
Output is correct |
29 |
Correct |
85 ms |
111332 KB |
Output is correct |
30 |
Correct |
95 ms |
111332 KB |
Output is correct |