# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
320252 |
2020-11-08T06:19:53 Z |
Marlov |
Kitchen (BOI19_kitchen) |
C++14 |
|
1 ms |
1008 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];
int mina=maxV;
int tt=0;
//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,INF);
}
for(int i=1;i<=N;i++){
cin>>A[i];
mina=min(mina,A[i]);
tt+=A[i];
}
if(mina<K){
cout<<"Impossible"<<'\n';
return 0;
}
for(int i=1;i<=M;i++){
cin>>B[i];
}
dp[0][0]=tt-(N*K);
for(int i=1;i<=M;i++){
//possibly forgetting to propigate last values
for(int j=0;j<min(N,B[i]);j++){
dp[i][j]=dp[i-1][j];
}
for(int j=min(N,B[i]);j<=N*K;j++){
int f1=dp[i-1][j];
int f2=dp[i-1][j-min(N,B[i])]-(B[i]-min(N,B[i]));
if(f1>0&&f2>0){
dp[i][j]=min(f1,f2);
}else if(f1>0&&f2<0){
dp[i][j]=f2;
}
}
}
if(dp[M][N*K]>0){
cout<<"Impossible"<<'\n';
return 0;
}else{
cout<<-1*dp[M][N*K]<<'\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 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |