답안 #794123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794123 2023-07-26T09:35:15 Z gun_gan Kitchen (BOI19_kitchen) C++17
100 / 100
80 ms 111532 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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 111308 KB Output is correct
2 Correct 38 ms 111316 KB Output is correct
3 Correct 39 ms 111264 KB Output is correct
4 Correct 40 ms 111352 KB Output is correct
5 Correct 39 ms 111256 KB Output is correct
6 Correct 39 ms 111288 KB Output is correct
7 Correct 39 ms 111276 KB Output is correct
8 Correct 39 ms 111308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 111308 KB Output is correct
2 Correct 38 ms 111316 KB Output is correct
3 Correct 39 ms 111264 KB Output is correct
4 Correct 40 ms 111352 KB Output is correct
5 Correct 39 ms 111256 KB Output is correct
6 Correct 39 ms 111288 KB Output is correct
7 Correct 39 ms 111276 KB Output is correct
8 Correct 39 ms 111308 KB Output is correct
9 Correct 40 ms 111268 KB Output is correct
10 Correct 41 ms 111308 KB Output is correct
11 Correct 40 ms 111256 KB Output is correct
12 Correct 40 ms 111288 KB Output is correct
13 Correct 40 ms 111308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 111308 KB Output is correct
2 Correct 64 ms 111360 KB Output is correct
3 Correct 76 ms 111360 KB Output is correct
4 Correct 76 ms 111336 KB Output is correct
5 Correct 74 ms 111276 KB Output is correct
6 Correct 64 ms 111344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 111292 KB Output is correct
2 Correct 42 ms 111320 KB Output is correct
3 Correct 42 ms 111320 KB Output is correct
4 Correct 43 ms 111308 KB Output is correct
5 Correct 39 ms 111308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 111308 KB Output is correct
2 Correct 38 ms 111316 KB Output is correct
3 Correct 39 ms 111264 KB Output is correct
4 Correct 40 ms 111352 KB Output is correct
5 Correct 39 ms 111256 KB Output is correct
6 Correct 39 ms 111288 KB Output is correct
7 Correct 39 ms 111276 KB Output is correct
8 Correct 39 ms 111308 KB Output is correct
9 Correct 40 ms 111268 KB Output is correct
10 Correct 41 ms 111308 KB Output is correct
11 Correct 40 ms 111256 KB Output is correct
12 Correct 40 ms 111288 KB Output is correct
13 Correct 40 ms 111308 KB Output is correct
14 Correct 68 ms 111308 KB Output is correct
15 Correct 64 ms 111360 KB Output is correct
16 Correct 76 ms 111360 KB Output is correct
17 Correct 76 ms 111336 KB Output is correct
18 Correct 74 ms 111276 KB Output is correct
19 Correct 64 ms 111344 KB Output is correct
20 Correct 43 ms 111292 KB Output is correct
21 Correct 42 ms 111320 KB Output is correct
22 Correct 42 ms 111320 KB Output is correct
23 Correct 43 ms 111308 KB Output is correct
24 Correct 39 ms 111308 KB Output is correct
25 Correct 66 ms 111532 KB Output is correct
26 Correct 66 ms 111308 KB Output is correct
27 Correct 56 ms 111252 KB Output is correct
28 Correct 67 ms 111348 KB Output is correct
29 Correct 69 ms 111292 KB Output is correct
30 Correct 80 ms 111356 KB Output is correct