# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
859167 |
2023-10-09T21:22:07 Z |
NK_ |
Kitchen (BOI19_kitchen) |
C++17 |
|
56 ms |
68956 KB |
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using pi = pair<int, int>;
using vi = V<int>;
using vpi = V<pi>;
using ll = long long;
using pl = pair<ll, ll>;
using vpl = V<pl>;
using vl = V<ll>;
using db = long double;
template<class T> using pq = priority_queue<T, V<T>, greater<T>>;
const int MOD = 1e9 + 7;
const ll INFL = ll(1e17);
const int LG = 18;
const int nax = 305;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, M, K; cin >> N >> M >> K;
vi A(N); for(auto& x : A) {
cin >> x;
if (x < K) {
cout << "Impossible" << nl;
exit(0-0);
}
}
vi B(M); for(auto& x : B) cin >> x;
int S = accumulate(begin(B), end(B), 0);
int SUM = accumulate(begin(A), end(A), 0);
V<vi> dp(M+1, vi(S+1, -MOD));
dp[0][0] = 0;
for(int i = 0; i < M; i++) {
for(int x = 0; x <= S; x++) {
int amt = min(N, B[i]);
if ((x + B[i]) <= S) dp[i+1][x+B[i]] = max(dp[i+1][x+B[i]], dp[i][x] + amt);
}
}
for(int x = SUM; x <= S; x++) {
// cout << x << " => " << dp[M][x] << nl;
if (dp[M][x] >= N * K) {
cout << x - SUM << nl;
exit(0-0);
}
}
cout << "Impossible" << nl;
exit(0-0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
68956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |