This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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, 0);
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 = 7; i >= 1; i--) {
if(i >= work_hours[j])
dp[i] = max(dp[i-work_hours[j]] + min(n, work_hours[j]), dp[i]);
}
}
int ans = INT_MAX;
for(int i = 0; i<=300*m; i++) {
if(dp[i] >= n*k && i >= sum) ans = min(ans, i-sum);
}
if(ans == INT_MAX) ex();
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |