Submission #793748

# Submission time Handle Problem Language Result Execution time Memory
793748 2023-07-26T06:15:35 Z andecaandeci Kitchen (BOI19_kitchen) C++17
100 / 100
83 ms 111468 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 305;
int N, M, K;

int dp[MX][MX * MX];
int a[MX], b[MX];

int main() {
      cin.tie(0); ios_base::sync_with_stdio(0);

      memset(dp, -1, sizeof dp);

      cin >> N >> M >> K;
      ll sum = 0;
      bool bad = M < K;
      for(int i = 1; i <= N; i++) {
            cin >> a[i];
            sum += a[i];
            bad |= a[i] < K;
      }

      for(int i = 1; i <= M; i++) cin >> b[i];

      if(bad) {
            cout << "Impossible\n";
            return 0;
      }

      dp[0][0] = 0;
      for(int i = 1; i <= M; i++) {
            for(int s = 0; s < MX * MX; s++) {
                  dp[i][s] = max(dp[i][s], dp[i - 1][s]);
                  if(s >= b[i] && dp[i - 1][s - b[i]] != -1) dp[i][s] = max(dp[i][s], dp[i - 1][s - b[i]] + min(N, b[i]));
            }
      }

      for(int s = sum; s < MX * MX; s++) {
            if(dp[M][s] >= K * N) {
                  cout << s - sum << '\n';
                  return 0;
            }
      }

      cout << "Impossible\n";
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 111316 KB Output is correct
2 Correct 37 ms 111292 KB Output is correct
3 Correct 40 ms 111352 KB Output is correct
4 Correct 45 ms 111444 KB Output is correct
5 Correct 37 ms 111312 KB Output is correct
6 Correct 35 ms 111264 KB Output is correct
7 Correct 35 ms 111308 KB Output is correct
8 Correct 36 ms 111352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 111316 KB Output is correct
2 Correct 37 ms 111292 KB Output is correct
3 Correct 40 ms 111352 KB Output is correct
4 Correct 45 ms 111444 KB Output is correct
5 Correct 37 ms 111312 KB Output is correct
6 Correct 35 ms 111264 KB Output is correct
7 Correct 35 ms 111308 KB Output is correct
8 Correct 36 ms 111352 KB Output is correct
9 Correct 37 ms 111288 KB Output is correct
10 Correct 37 ms 111308 KB Output is correct
11 Correct 38 ms 111308 KB Output is correct
12 Correct 45 ms 111468 KB Output is correct
13 Correct 49 ms 111308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 111268 KB Output is correct
2 Correct 64 ms 111356 KB Output is correct
3 Correct 71 ms 111356 KB Output is correct
4 Correct 73 ms 111280 KB Output is correct
5 Correct 75 ms 111312 KB Output is correct
6 Correct 61 ms 111260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 111352 KB Output is correct
2 Correct 40 ms 111236 KB Output is correct
3 Correct 41 ms 111336 KB Output is correct
4 Correct 41 ms 111352 KB Output is correct
5 Correct 36 ms 111296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 111316 KB Output is correct
2 Correct 37 ms 111292 KB Output is correct
3 Correct 40 ms 111352 KB Output is correct
4 Correct 45 ms 111444 KB Output is correct
5 Correct 37 ms 111312 KB Output is correct
6 Correct 35 ms 111264 KB Output is correct
7 Correct 35 ms 111308 KB Output is correct
8 Correct 36 ms 111352 KB Output is correct
9 Correct 37 ms 111288 KB Output is correct
10 Correct 37 ms 111308 KB Output is correct
11 Correct 38 ms 111308 KB Output is correct
12 Correct 45 ms 111468 KB Output is correct
13 Correct 49 ms 111308 KB Output is correct
14 Correct 65 ms 111268 KB Output is correct
15 Correct 64 ms 111356 KB Output is correct
16 Correct 71 ms 111356 KB Output is correct
17 Correct 73 ms 111280 KB Output is correct
18 Correct 75 ms 111312 KB Output is correct
19 Correct 61 ms 111260 KB Output is correct
20 Correct 46 ms 111352 KB Output is correct
21 Correct 40 ms 111236 KB Output is correct
22 Correct 41 ms 111336 KB Output is correct
23 Correct 41 ms 111352 KB Output is correct
24 Correct 36 ms 111296 KB Output is correct
25 Correct 58 ms 111264 KB Output is correct
26 Correct 65 ms 111268 KB Output is correct
27 Correct 53 ms 111348 KB Output is correct
28 Correct 65 ms 111348 KB Output is correct
29 Correct 65 ms 111352 KB Output is correct
30 Correct 83 ms 111280 KB Output is correct