#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
const int MAXN2 = 310*310;
int a[MAXN];
int b[MAXN];
int dp[MAXN2][MAXN];
int main(){
int n,m,k;
cin>>n>>m>>k;
int holdsum = 0;
int holdsum2 = 0;
for(int i=1;i<=n;i++){
cin>>a[i];
holdsum+=a[i];
if(a[i]<k){
cout<<"Impossible"<<endl;
return 0;
}
}
for(int i=1;i<=m;i++){
cin>>b[i];
holdsum2 += b[i];
}
for(int i=0;i<=holdsum2;i++){
for(int j=1;j<=m;j++){
dp[i][j] = dp[i][j-1];
if(i-b[j]>=0){
dp[i][j] = max(dp[i][j-1],dp[i-b[j]][j-1]+min(b[j],n));
}
}
}
for(int i=holdsum;i<=holdsum2;i++){
for(int j=1;j<=m;j++){
if(dp[i][j]>=n*k){
cout<<i-holdsum<<endl;
return 0;
}
}
}
cout<<"Impossible"<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
636 KB |
Output is correct |
2 |
Incorrect |
5 ms |
632 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
636 KB |
Output is correct |
2 |
Incorrect |
5 ms |
632 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
114 ms |
80248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1912 KB |
Output is correct |
2 |
Correct |
5 ms |
1400 KB |
Output is correct |
3 |
Correct |
6 ms |
1816 KB |
Output is correct |
4 |
Correct |
6 ms |
2168 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
636 KB |
Output is correct |
2 |
Incorrect |
5 ms |
632 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |