답안 #657381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657381 2022-11-09T19:02:24 Z bicsi Kitchen (BOI19_kitchen) C++14
100 / 100
44 ms 724 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m, k; cin >> n >> m >> k;

  int g = 0;
  for (int i = 0; i < n; ++i) {
    int ai; cin >> ai; 
    if (ai < k) {
      cout << "Impossible\n";
      return 0;
    }
    g += ai;
  }

  vector<int> dp(100000, -1e9);
  dp[0] = 0;
  int mx = 0;
  for (int i = 0; i < m; ++i) {
    int bi; cin >> bi;
    int val = min(bi, n);
    for (int j = mx; j >= 0; --j) 
      if (dp[j] >= 0)
        dp[j + bi] = max(dp[j + bi], dp[j] + val);
    mx += bi;
  }
  
  for (int i = g; i <= mx; ++i)
    if (dp[i] >= n * k) {
      cout << i - g << endl;
      return 0;
    }
  cout << "Impossible\n";

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 684 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 684 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 684 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 684 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 680 KB Output is correct
13 Correct 1 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 712 KB Output is correct
2 Correct 11 ms 700 KB Output is correct
3 Correct 28 ms 692 KB Output is correct
4 Correct 44 ms 692 KB Output is correct
5 Correct 39 ms 596 KB Output is correct
6 Correct 10 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 688 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 684 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 684 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 680 KB Output is correct
13 Correct 1 ms 680 KB Output is correct
14 Correct 15 ms 712 KB Output is correct
15 Correct 11 ms 700 KB Output is correct
16 Correct 28 ms 692 KB Output is correct
17 Correct 44 ms 692 KB Output is correct
18 Correct 39 ms 596 KB Output is correct
19 Correct 10 ms 680 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 688 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 8 ms 596 KB Output is correct
26 Correct 12 ms 704 KB Output is correct
27 Correct 9 ms 680 KB Output is correct
28 Correct 23 ms 680 KB Output is correct
29 Correct 31 ms 596 KB Output is correct
30 Correct 44 ms 684 KB Output is correct