#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, 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, 0, 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 |
1 ms |
1024 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1024 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1024 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1024 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
93468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
14592 KB |
Output is correct |
2 |
Correct |
13 ms |
14592 KB |
Output is correct |
3 |
Incorrect |
13 ms |
14592 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1024 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1024 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |