# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
566988 |
2022-05-23T07:05:14 Z |
MrDeboo |
Kitchen (BOI19_kitchen) |
C++17 |
|
1000 ms |
160848 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
int a[n];
int b[m];
for(auto &i:a)cin>>i;
for(auto &i:b)cin>>i;
if(m<k){cout<<"Impossible";return 0;}
for(int i=0;i<n;i++){
if(a[i]<k){cout<<"Impossible";return 0;}
}
int dp[m+1][300*m+1];
memset(dp,0,sizeof dp);
dp[0][0]=1;
for(int i=0;i<m;i++){
for(int w=m-1;w>=0;w--){
for(int j=300*m-b[i];j>=0;j--){
if(dp[w][j])dp[w+1][j+b[i]]=1;
}
}
}
int sm=0;
int ans=INT_MAX;
for(auto &i:a)sm+=i;
for(int i=k;i<=m;i++){
for(int w=sm;w<=300*m;w++){
if(dp[i][w]){
ans=min(ans,w-sm);
}
}
}
if(ans==INT_MAX)cout<<"Impossible";
else cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
852 KB |
Output is correct |
10 |
Correct |
2 ms |
852 KB |
Output is correct |
11 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
160848 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
4164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
852 KB |
Output is correct |
10 |
Correct |
2 ms |
852 KB |
Output is correct |
11 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |