# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
651026 |
2022-10-16T13:39:10 Z |
dooompy |
Kitchen (BOI19_kitchen) |
C++17 |
|
72 ms |
119708 KB |
#include "bits/stdc++.h"
using namespace std;
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
bool is = false;
for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
return o << '}';
}
#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif
using ll = long long;
int a[305], b[305];
int dp[305][100005]; //
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("", "r", stdin);
// freopen("", "w", stdout);
int n, m, k; cin >> n >> m >> k;
int totala = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
totala += a[i];
if (a[i] < k) {
cout << "Impossible"; return 0;
}
}
for (int i = 1; i <= m; i++) cin >> b[i];
fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(dp[0][0]), -1);
dp[0][0] = 0;
int sum = 0;
for (int i = 1; i <= m; i++) {
sum += b[i];
for (int j = sum; j >= 0; j--) {
if (dp[i-1][j] < 0) continue;
dp[i][j] = dp[i-1][j];
dp[i][j + b[i]] = max(dp[i][j + b[i]], dp[i-1][j] + min(n, b[i]));
}
}
for (int i = totala; i <= 100000; i++) {
if (dp[m][i] >= n * k) {
cout << i - totala;
return 0;
}
}
cout << "Impossible";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
119700 KB |
Output is correct |
2 |
Correct |
49 ms |
119628 KB |
Output is correct |
3 |
Correct |
46 ms |
119656 KB |
Output is correct |
4 |
Correct |
46 ms |
119624 KB |
Output is correct |
5 |
Correct |
47 ms |
119620 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
51 ms |
119604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
119700 KB |
Output is correct |
2 |
Correct |
49 ms |
119628 KB |
Output is correct |
3 |
Correct |
46 ms |
119656 KB |
Output is correct |
4 |
Correct |
46 ms |
119624 KB |
Output is correct |
5 |
Correct |
47 ms |
119620 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
51 ms |
119604 KB |
Output is correct |
9 |
Correct |
49 ms |
119708 KB |
Output is correct |
10 |
Correct |
46 ms |
119676 KB |
Output is correct |
11 |
Correct |
47 ms |
119672 KB |
Output is correct |
12 |
Correct |
48 ms |
119676 KB |
Output is correct |
13 |
Correct |
53 ms |
119592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
119680 KB |
Output is correct |
2 |
Correct |
59 ms |
119592 KB |
Output is correct |
3 |
Correct |
61 ms |
119640 KB |
Output is correct |
4 |
Correct |
68 ms |
119684 KB |
Output is correct |
5 |
Correct |
67 ms |
119684 KB |
Output is correct |
6 |
Correct |
64 ms |
119640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
119696 KB |
Output is correct |
2 |
Correct |
48 ms |
119600 KB |
Output is correct |
3 |
Correct |
51 ms |
119596 KB |
Output is correct |
4 |
Correct |
50 ms |
119584 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
119700 KB |
Output is correct |
2 |
Correct |
49 ms |
119628 KB |
Output is correct |
3 |
Correct |
46 ms |
119656 KB |
Output is correct |
4 |
Correct |
46 ms |
119624 KB |
Output is correct |
5 |
Correct |
47 ms |
119620 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
51 ms |
119604 KB |
Output is correct |
9 |
Correct |
49 ms |
119708 KB |
Output is correct |
10 |
Correct |
46 ms |
119676 KB |
Output is correct |
11 |
Correct |
47 ms |
119672 KB |
Output is correct |
12 |
Correct |
48 ms |
119676 KB |
Output is correct |
13 |
Correct |
53 ms |
119592 KB |
Output is correct |
14 |
Correct |
61 ms |
119680 KB |
Output is correct |
15 |
Correct |
59 ms |
119592 KB |
Output is correct |
16 |
Correct |
61 ms |
119640 KB |
Output is correct |
17 |
Correct |
68 ms |
119684 KB |
Output is correct |
18 |
Correct |
67 ms |
119684 KB |
Output is correct |
19 |
Correct |
64 ms |
119640 KB |
Output is correct |
20 |
Correct |
46 ms |
119696 KB |
Output is correct |
21 |
Correct |
48 ms |
119600 KB |
Output is correct |
22 |
Correct |
51 ms |
119596 KB |
Output is correct |
23 |
Correct |
50 ms |
119584 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
56 ms |
119628 KB |
Output is correct |
26 |
Correct |
58 ms |
119632 KB |
Output is correct |
27 |
Correct |
49 ms |
119600 KB |
Output is correct |
28 |
Correct |
64 ms |
119628 KB |
Output is correct |
29 |
Correct |
62 ms |
119680 KB |
Output is correct |
30 |
Correct |
72 ms |
119684 KB |
Output is correct |