#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>;
int dp[301][90001];
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;}
}
memset(dp,-1,sizeof dp);
dp[0][0]=0;
for(int i=0;i<m;i++){
for(int w=299;w>=0;w--){
for(int j=90000-b[i];j>=0;j--){
if(dp[w][j]!=-1)dp[w+1][j+min(n,b[i])]=max(dp[w+1][j+min(n,b[i])],dp[w][j]+b[i]);
}
}
}
int sm=0;
int ans=INT_MAX;
for(auto &i:a)sm+=i;
for(int i=k;i<=m;i++){
for(int w=n*k;w<=90000;w++){
if(dp[i][w]>=sm){
ans=min(ans,dp[i][w]-sm);
}
}
}
if(ans==INT_MAX)cout<<"Impossible";
else cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
78 ms |
106232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
78 ms |
106232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
106260 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
945 ms |
106324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
78 ms |
106232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |