답안 #131101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131101 2019-07-16T13:00:21 Z IOrtroiii Kitchen (BOI19_kitchen) C++14
100 / 100
29 ms 788 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 305;
const int M = N * N;

int a[N];
int b[N];
int f[M];

int main() {
   ios_base::sync_with_stdio(false);
   int n, m, k;
   cin >> n >> m >> k;
   for (int i = 1; i <= n; ++i) {
      cin >> a[i];
   }
   for (int i = 1; i <= m; ++i) {
      cin >> b[i];
   }
   if (*min_element(a + 1, a + n + 1) < k) {
      cout << "Impossible\n";
      return 0;
   }
   memset(f, -69, sizeof f);
   f[0] = 0;
   for (int i = 1; i <= m; ++i) {
      for (int j = M - 1; j >= b[i]; --j) {
         f[j] = max(f[j], f[j - b[i]]  + min(b[i], n));
      }
   }
   int sum = accumulate(a + 1, a + n + 1, 0);
   for (int i = sum; i < M; ++i) {
      if (f[i] >= n * k) {
         cout << i - sum << "\n";
         return 0;
      }
   }
   cout << "Impossible\n";
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 4 ms 632 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 752 KB Output is correct
2 Correct 22 ms 632 KB Output is correct
3 Correct 29 ms 632 KB Output is correct
4 Correct 29 ms 752 KB Output is correct
5 Correct 28 ms 760 KB Output is correct
6 Correct 21 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 760 KB Output is correct
2 Correct 6 ms 760 KB Output is correct
3 Correct 6 ms 632 KB Output is correct
4 Correct 6 ms 760 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 4 ms 632 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 26 ms 752 KB Output is correct
15 Correct 22 ms 632 KB Output is correct
16 Correct 29 ms 632 KB Output is correct
17 Correct 29 ms 752 KB Output is correct
18 Correct 28 ms 760 KB Output is correct
19 Correct 21 ms 760 KB Output is correct
20 Correct 6 ms 760 KB Output is correct
21 Correct 6 ms 760 KB Output is correct
22 Correct 6 ms 632 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 21 ms 756 KB Output is correct
26 Correct 24 ms 764 KB Output is correct
27 Correct 21 ms 760 KB Output is correct
28 Correct 25 ms 632 KB Output is correct
29 Correct 26 ms 760 KB Output is correct
30 Correct 29 ms 788 KB Output is correct