#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << " " <<
#define nl << "\n"
//total <, min < k
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n, m, k; cin >> n >> m >> k;
int a[n], b[m];
for(int &i : a) cin >> i;
for(int &i : b) cin >> i;
int x = accumulate(b, b+m, 0LL);
int y = accumulate(a, a+n, 0LL);
vector<int> dp(x+1, 0);
for(int i=0; i<m; ++i){
for(int j=x; j>=b[i]; --j){
dp[j] = max(dp[j], dp[j-b[i]] + min(n, b[i]));
}
}
if(*min_element(a, a+n)>=k){
for(int i=y; i<=x; ++i){
if(dp[i]>=k*n){
cout << i-y;
return 0;
}
}
}
cout << "Impossible";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |