#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ex() {
cout << "Impossible";
exit(0);
}
int main() {
int n, m, k;
cin >> n >> m >> k;
vector<int> dp (300 * 300 + 1, -1);
vector<int> values(n), work_hours(m);
dp[0] = 0;
int sum = 0;
for(int &i : values) {cin >> i; sum+=i;}
for(int &i : work_hours) cin >> i;
if(m < k) ex();
for(int j = 0; j < m; j++) {
for(int i = 300*300; i >= 1; i--) {
if(i >= work_hours[j] && dp[i-work_hours[j]] != -1) {
dp[i] = max(dp[i-work_hours[j]] + min(n, work_hours[j]), dp[i]);
}
}
}
int ans = INT_MAX;
for(int i = sum; i<=300*m; i++) {
if(dp[i] >= n*k) ans = min(ans, i-sum);
}
if(ans == INT_MAX) ex();
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
604 KB |
Output is correct |
2 |
Correct |
17 ms |
604 KB |
Output is correct |
3 |
Correct |
23 ms |
796 KB |
Output is correct |
4 |
Correct |
27 ms |
800 KB |
Output is correct |
5 |
Correct |
24 ms |
604 KB |
Output is correct |
6 |
Correct |
15 ms |
792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
5 ms |
856 KB |
Output is correct |
3 |
Correct |
3 ms |
604 KB |
Output is correct |
4 |
Correct |
5 ms |
796 KB |
Output is correct |
5 |
Incorrect |
3 ms |
792 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |