답안 #552011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552011 2022-04-22T07:54:50 Z ollel Kitchen (BOI19_kitchen) C++14
100 / 100
323 ms 13104 KB
using namespace std;
#include <bits/stdc++.h>

#define rep(i,a,b) for(int i = a; i < b; i++)
typedef vector<int> vi;
typedef vector<vi> vvi;

int n, m, k;
vi a, b;

int main() {
  cin >> n >> m >> k;
  a.resize(n);
  b.resize(m);
  rep(i,0,n) cin >> a[i];
  rep(i,0,m) cin >> b[i];

  rep(i,0,n) if (a[i] < k) {
    cout << "Impossible\n";
    exit(0);
  }


  // dp[i] = num
  // dp[i] = maximum sum2 with sum1 = i?

  const int maxs = 3300*330;
  vvi dp(2, vi(maxs, -1));
  dp[0][0] = 0; dp[1][0] = 0;
  rep(i,0,m) {
    int sum1 = b[i];
    int sum2 = min(b[i], n);
    int i1 = i&1;
    rep(j,0,maxs - sum1) {
      if (dp[i1][j] == -1) continue;
      dp[i1^1][j + sum1] = max(dp[i1^1][j + sum1], dp[i1][j] + sum2);
      dp[i1^1][j] = max(dp[i1^1][j], dp[i1][j]);
    }
  }
  int minimi = n * k;
  int start = 0;
  rep(i,0,n) start += a[i];
  rep(i, start, maxs) {
    if (dp[0][i] >= minimi || dp[1][i] >= minimi) {
      cout << (i - start) << endl;
      exit(0);
    }
  }
  cout << "Impossible" << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 7 ms 13012 KB Output is correct
4 Correct 8 ms 13012 KB Output is correct
5 Correct 9 ms 12984 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 8 ms 13012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 7 ms 13012 KB Output is correct
4 Correct 8 ms 13012 KB Output is correct
5 Correct 9 ms 12984 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 8 ms 13012 KB Output is correct
9 Correct 17 ms 13012 KB Output is correct
10 Correct 19 ms 13012 KB Output is correct
11 Correct 18 ms 13012 KB Output is correct
12 Correct 19 ms 13012 KB Output is correct
13 Correct 19 ms 13012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 236 ms 13012 KB Output is correct
2 Correct 192 ms 13012 KB Output is correct
3 Correct 307 ms 13012 KB Output is correct
4 Correct 276 ms 13100 KB Output is correct
5 Correct 255 ms 13096 KB Output is correct
6 Correct 189 ms 13012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 13012 KB Output is correct
2 Correct 55 ms 12976 KB Output is correct
3 Correct 39 ms 13012 KB Output is correct
4 Correct 39 ms 13104 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 7 ms 13012 KB Output is correct
4 Correct 8 ms 13012 KB Output is correct
5 Correct 9 ms 12984 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 8 ms 13012 KB Output is correct
9 Correct 17 ms 13012 KB Output is correct
10 Correct 19 ms 13012 KB Output is correct
11 Correct 18 ms 13012 KB Output is correct
12 Correct 19 ms 13012 KB Output is correct
13 Correct 19 ms 13012 KB Output is correct
14 Correct 236 ms 13012 KB Output is correct
15 Correct 192 ms 13012 KB Output is correct
16 Correct 307 ms 13012 KB Output is correct
17 Correct 276 ms 13100 KB Output is correct
18 Correct 255 ms 13096 KB Output is correct
19 Correct 189 ms 13012 KB Output is correct
20 Correct 40 ms 13012 KB Output is correct
21 Correct 55 ms 12976 KB Output is correct
22 Correct 39 ms 13012 KB Output is correct
23 Correct 39 ms 13104 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 182 ms 13060 KB Output is correct
26 Correct 216 ms 13012 KB Output is correct
27 Correct 175 ms 13012 KB Output is correct
28 Correct 221 ms 13012 KB Output is correct
29 Correct 264 ms 13012 KB Output is correct
30 Correct 323 ms 13012 KB Output is correct