제출 #896721

#제출 시각아이디문제언어결과실행 시간메모리
896721boxKitchen (BOI19_kitchen)C++17
100 / 100
23 ms640 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL template <class T, class... U> void bug_h(const T& t, const U&... u) { cerr << t; ((cerr << " | " << u), ...); cerr << endl; } #define bug(...) cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; bug_h(__VA_ARGS__) #else #define cerr if (false) cerr #define bug(...) #endif #define ar array #define all(v) std::begin(v), std::end(v) #define sz(v) int(std::size(v)) typedef long long i64; typedef vector<int> vi; typedef pair<int, int> pi; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N, M, K; cin >> N >> M >> K; vi A(N), B(M); for (auto &x : A) cin >> x; for (auto &x : B) cin >> x; if (*min_element(all(A)) < K) { cout << "Impossible\n"; return 0; } int sum_a = accumulate(all(A), 0); const int MAXB = 300; vi dp(MAXB * M + 1, -N * M); dp[0] = 0; for (int i = 0; i < M; i++) { int weight = B[i], value = min(B[i], N); for (int j = MAXB * M; j >= weight; j--) dp[j] = max(dp[j], dp[j - weight] + value); } for (int j = sum_a; j <= MAXB * M; j++) if (dp[j] >= N * K) { cout << j - sum_a << '\n'; return 0; } cout << "Impossible\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...