제출 #169383

#제출 시각아이디문제언어결과실행 시간메모리
169383rulerKitchen (BOI19_kitchen)C++14
21 / 100
128 ms95352 KiB
// IOI 2021 #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ends ' ' #define die(x) return cout << x << endl, 0 #define all(v) v.begin(), v.end() #define sz(x) (int)(x.size()) void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); } #define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__) typedef long long ll; typedef pair<int, int> pii; const ll INF = 1e9; const ll MOD = 1e9 + 7; //////////////////////////////////////////////////////////////////// const int N = 3e2 + 5; int B[N], DP[N][N * N]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, m, k, sum = 0; cin >> n >> m >> k; if (m < k) die("Impossible"); for (int i = 0; i < n; i++) { int a; cin >> a; sum += a; if (a < k) die("Impossible"); } for (int i = 1; i <= m; i++) for (int j = 0; j < N * N; j++) DP[i][j] = -1; DP[0][0] = 0; for (int i = 1; i <= m; i++) cin >> B[i]; for (int i = 1; i <= m; i++) for (int j = 0; j < N * N; j++) { DP[i][j] = DP[i - 1][j]; if (j >= B[i] && DP[i - 1][j - B[i]] != -1) DP[i][j] = max(DP[i][j], DP[i - 1][j - B[i]] + min(B[i], n)); } for (int i = 0; i + sum < N * N; i++) if (DP[m][i + sum] >= n * k) die(i); cout << "Impossible" << endl; return 0; }
#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...