#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, -1e18);
dp[0] = 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 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
876 KB |
Output is correct |
2 |
Correct |
14 ms |
748 KB |
Output is correct |
3 |
Correct |
15 ms |
748 KB |
Output is correct |
4 |
Correct |
25 ms |
1004 KB |
Output is correct |
5 |
Correct |
26 ms |
1004 KB |
Output is correct |
6 |
Correct |
12 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
18 ms |
876 KB |
Output is correct |
15 |
Correct |
14 ms |
748 KB |
Output is correct |
16 |
Correct |
15 ms |
748 KB |
Output is correct |
17 |
Correct |
25 ms |
1004 KB |
Output is correct |
18 |
Correct |
26 ms |
1004 KB |
Output is correct |
19 |
Correct |
12 ms |
748 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
16 ms |
748 KB |
Output is correct |
26 |
Correct |
17 ms |
876 KB |
Output is correct |
27 |
Correct |
6 ms |
492 KB |
Output is correct |
28 |
Correct |
14 ms |
748 KB |
Output is correct |
29 |
Correct |
18 ms |
876 KB |
Output is correct |
30 |
Correct |
26 ms |
1004 KB |
Output is correct |