답안 #800884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800884 2023-08-02T01:19:50 Z christinelynn Kitchen (BOI19_kitchen) C++17
29 / 100
20 ms 668 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

const int N = 3e2 + 5;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n, m, k, sum1 = 0, sum2 = 0;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < k) {
      cout << "Impossible\n";
      return 0;
    }
    sum1 += a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    sum2 += b[i];
  }
  for (int i = 1; i <= sum2; i++) dp[i] = -1e9;
  for (int i = 1; i <= m; i++) {
    for (int j = sum2; j >= b[i]; j--) dp[j] = max(dp[j], dp[j - b[i]] + 1);
  }
  for (int i = sum1; i <= sum2; i++) {
    if (dp[i] >= k) {
      cout << i - sum1 << "\n";
      return 0;
    }
  }
  cout << "Impossible\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 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 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 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 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Incorrect 1 ms 328 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 592 KB Output is correct
2 Correct 11 ms 552 KB Output is correct
3 Correct 12 ms 468 KB Output is correct
4 Correct 20 ms 640 KB Output is correct
5 Correct 20 ms 668 KB Output is correct
6 Correct 9 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 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 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Incorrect 1 ms 328 KB Output isn't correct
12 Halted 0 ms 0 KB -