#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define int long long
//#define ld long double
using namespace std;
using ll=long long;
const int inf = 2e18;
const int MN = 305;
const int mod=1e9+7;
int n,m,k;
int a[MN],b[MN];
int dp[MN][MN*MN];
int mx,sum;
inline void solve() {
cin>>n>>m>>k;
for (int i=1; i<=n; i++) {
cin>>a[i];
mx+=a[i];
}
for (int i=1; i<=m; i++) {
cin>>b[i];
sum+=b[i];
}
for (int i=1; i<=n; i++) {
if(a[i]<k) {
cout<<"Impossible";
return;
}
}
for (int i=1; i<=m; i++) {
for (int w=sum; w>=0; w--) {
dp[i][w]=dp[i-1][w];
if(w+b[i]<=sum) dp[i][w+b[i]]=max(dp[i][w+b[i]],dp[i-1][w]+min(b[i],n));
}
}
for (int i=mx; i<=sum; i++) {
if(dp[m][i]>=n*k) {
cout<<i-mx;
return;
}
}
cout<<"Impossible";
// cout<<mn;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
// preprocess();
// cin>>t;
while(t--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
66 ms |
136088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
852 KB |
Output is correct |
2 |
Correct |
1 ms |
724 KB |
Output is correct |
3 |
Correct |
1 ms |
852 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |