#include <bits/stdc++.h>
using namespace std;
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << enl;}
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 998244353
#define LOGN 20
#define MAXN 305
int dp[MAXN][90005];
vector<int> meal, chef;
int main() {
fast
int N, M, K;
cin >> N >> M >> K;
meal = vector<int>(N+1);
chef = vector<int>(M+1);
int sum = 0;
for (int i = 1; i <= N; i++)
cin >> meal[i], sum += meal[i];
for (int i = 1; i <= M; i++)
cin >> chef[i];
for (int i = 0; i <= M; i++) {
for (int total = 0; total <= 90000; total++)
dp[i][total] = -1e8;
}
dp[0][0] = 0;
for (int i = 1; i <= M; i++) {
for (int total = 0; total <= 90000; total++) {
dp[i][total] = dp[i-1][total];
if (total - chef[i] >= 0)
dp[i][total] = max(dp[i][total], dp[i-1][total - chef[i]] + min(chef[i], N));
}
}
int ans = INT_MAX;
for (int total = sum; total <= 90000; total++) {
if (dp[M][total] >= N * K)
ans = min(ans, total - sum);
}
if (ans == INT_MAX)
cout << "Impossible\n";
else
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1352 KB |
Output is correct |
4 |
Correct |
1 ms |
1364 KB |
Output is correct |
5 |
Correct |
2 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Incorrect |
2 ms |
1352 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1352 KB |
Output is correct |
4 |
Correct |
1 ms |
1364 KB |
Output is correct |
5 |
Correct |
2 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Incorrect |
2 ms |
1352 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
92608 KB |
Output is correct |
2 |
Correct |
60 ms |
80164 KB |
Output is correct |
3 |
Correct |
89 ms |
106244 KB |
Output is correct |
4 |
Correct |
80 ms |
106280 KB |
Output is correct |
5 |
Correct |
76 ms |
102820 KB |
Output is correct |
6 |
Correct |
56 ms |
73932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
14772 KB |
Output is correct |
2 |
Correct |
15 ms |
14804 KB |
Output is correct |
3 |
Correct |
14 ms |
14676 KB |
Output is correct |
4 |
Correct |
11 ms |
14768 KB |
Output is correct |
5 |
Incorrect |
12 ms |
14768 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1352 KB |
Output is correct |
4 |
Correct |
1 ms |
1364 KB |
Output is correct |
5 |
Correct |
2 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Incorrect |
2 ms |
1352 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |