#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
#include <time.h>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int i_inf = 1e9;
const ll inf = 1e17;
const ll mod = 1000000007;
const ld eps = 1e-13;
const ld pi = 3.14159265359;
mt19937 _rand(time(NULL));
clock_t timer = clock();
const int mxn = 302;
int n, m, k;
int a[mxn];
int b[mxn];
int dp[mxn][mxn*mxn];
void solve(){
cin >> n >> m >> k;
fr(i, 0, n){
cin >> a[i];
}
fr(i, 0, m){
cin >> b[i];
}
fr(i, 0, n){
if(a[i] < k){
cout<<"Impossible"<<endl;
return;
}
}
fr(i, 1, mxn*mxn){
dp[0][i] = -i_inf;
}
fr(i, 1, m+1){
fr(j, 0, mxn*mxn){
dp[i][j] = dp[i-1][j];
if(b[i-1] <= j){
dp[i][j] = max(dp[i][j], dp[i-1][j-b[i-1]]+min(n, b[i-1]));
}
}
}
int sum = 0;
fr(i, 0, n) sum += a[i];
fr(i, sum, mxn*mxn){
if(dp[m][i] >= n*k){
cout<<i-sum<<endl;
return;
}
}
cout<<"Impossible"<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1408 KB |
Output is correct |
2 |
Correct |
1 ms |
1408 KB |
Output is correct |
3 |
Correct |
2 ms |
1408 KB |
Output is correct |
4 |
Correct |
1 ms |
1408 KB |
Output is correct |
5 |
Correct |
1 ms |
1408 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1408 KB |
Output is correct |
2 |
Correct |
1 ms |
1408 KB |
Output is correct |
3 |
Correct |
2 ms |
1408 KB |
Output is correct |
4 |
Correct |
1 ms |
1408 KB |
Output is correct |
5 |
Correct |
1 ms |
1408 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
6016 KB |
Output is correct |
10 |
Correct |
5 ms |
6016 KB |
Output is correct |
11 |
Correct |
5 ms |
6016 KB |
Output is correct |
12 |
Correct |
5 ms |
6016 KB |
Output is correct |
13 |
Correct |
7 ms |
6016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
93816 KB |
Output is correct |
2 |
Correct |
77 ms |
81356 KB |
Output is correct |
3 |
Correct |
94 ms |
107768 KB |
Output is correct |
4 |
Correct |
93 ms |
107788 KB |
Output is correct |
5 |
Correct |
98 ms |
104184 KB |
Output is correct |
6 |
Correct |
78 ms |
75000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
14976 KB |
Output is correct |
2 |
Correct |
21 ms |
14976 KB |
Output is correct |
3 |
Correct |
13 ms |
14976 KB |
Output is correct |
4 |
Correct |
17 ms |
14976 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1408 KB |
Output is correct |
2 |
Correct |
1 ms |
1408 KB |
Output is correct |
3 |
Correct |
2 ms |
1408 KB |
Output is correct |
4 |
Correct |
1 ms |
1408 KB |
Output is correct |
5 |
Correct |
1 ms |
1408 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
6016 KB |
Output is correct |
10 |
Correct |
5 ms |
6016 KB |
Output is correct |
11 |
Correct |
5 ms |
6016 KB |
Output is correct |
12 |
Correct |
5 ms |
6016 KB |
Output is correct |
13 |
Correct |
7 ms |
6016 KB |
Output is correct |
14 |
Correct |
81 ms |
93816 KB |
Output is correct |
15 |
Correct |
77 ms |
81356 KB |
Output is correct |
16 |
Correct |
94 ms |
107768 KB |
Output is correct |
17 |
Correct |
93 ms |
107788 KB |
Output is correct |
18 |
Correct |
98 ms |
104184 KB |
Output is correct |
19 |
Correct |
78 ms |
75000 KB |
Output is correct |
20 |
Correct |
19 ms |
14976 KB |
Output is correct |
21 |
Correct |
21 ms |
14976 KB |
Output is correct |
22 |
Correct |
13 ms |
14976 KB |
Output is correct |
23 |
Correct |
17 ms |
14976 KB |
Output is correct |
24 |
Correct |
0 ms |
384 KB |
Output is correct |
25 |
Correct |
73 ms |
75640 KB |
Output is correct |
26 |
Correct |
82 ms |
87416 KB |
Output is correct |
27 |
Correct |
79 ms |
57848 KB |
Output is correct |
28 |
Correct |
83 ms |
87800 KB |
Output is correct |
29 |
Correct |
95 ms |
89976 KB |
Output is correct |
30 |
Correct |
105 ms |
107784 KB |
Output is correct |