답안 #320915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320915 2020-11-10T08:54:27 Z kimbj0709 Kitchen (BOI19_kitchen) C++14
100 / 100
100 ms 1152 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 90050
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int n,m,k;
  cin >> n >> m >> k;
  vector<int> vect1,vect2;
  int input;
  int s = 0;
  for(int i=0;i<n;i++){
    cin >> input;
    if(input<k){
      cout << "Impossible";
      return 0;
    }
    s += input;
  }
  for(int i=0;i<m;i++){
    cin >> input;
    vect1.push_back(input);
  }
  vector<int> dp(maxn,INT_MIN);
  dp[0] = 0;
  for(int i=0;i<m;i++){
    int curradd = min(n,vect1[i]);
    for(int j=maxn-1-vect1[i];j>=0;j--){
      dp[j+vect1[i]] = max(dp[j+vect1[i]],dp[j]+curradd);
    }
  }
  int ans = INT_MAX;
  for(int i=s;i<dp.size();i++){
    if(dp[i]>=n*k){
      cout << i-s;
      return 0;
    }
  }
  cout << "Impossible";
}

Compilation message

kitchen.cpp: In function 'int32_t main()':
kitchen.cpp:34:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int i=s;i<dp.size();i++){
      |               ~^~~~~~~~~~
kitchen.cpp:33:7: warning: unused variable 'ans' [-Wunused-variable]
   33 |   int ans = INT_MAX;
      |       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1004 KB Output is correct
2 Correct 2 ms 1004 KB Output is correct
3 Correct 2 ms 1004 KB Output is correct
4 Correct 2 ms 1004 KB Output is correct
5 Correct 2 ms 1004 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1004 KB Output is correct
2 Correct 2 ms 1004 KB Output is correct
3 Correct 2 ms 1004 KB Output is correct
4 Correct 2 ms 1004 KB Output is correct
5 Correct 2 ms 1004 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
9 Correct 6 ms 1132 KB Output is correct
10 Correct 6 ms 1004 KB Output is correct
11 Correct 6 ms 1036 KB Output is correct
12 Correct 6 ms 1004 KB Output is correct
13 Correct 6 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 1004 KB Output is correct
2 Correct 67 ms 1004 KB Output is correct
3 Correct 100 ms 1004 KB Output is correct
4 Correct 89 ms 1152 KB Output is correct
5 Correct 98 ms 1004 KB Output is correct
6 Correct 72 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1004 KB Output is correct
2 Correct 14 ms 1004 KB Output is correct
3 Correct 14 ms 1004 KB Output is correct
4 Correct 15 ms 1004 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1004 KB Output is correct
2 Correct 2 ms 1004 KB Output is correct
3 Correct 2 ms 1004 KB Output is correct
4 Correct 2 ms 1004 KB Output is correct
5 Correct 2 ms 1004 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
9 Correct 6 ms 1132 KB Output is correct
10 Correct 6 ms 1004 KB Output is correct
11 Correct 6 ms 1036 KB Output is correct
12 Correct 6 ms 1004 KB Output is correct
13 Correct 6 ms 1004 KB Output is correct
14 Correct 87 ms 1004 KB Output is correct
15 Correct 67 ms 1004 KB Output is correct
16 Correct 100 ms 1004 KB Output is correct
17 Correct 89 ms 1152 KB Output is correct
18 Correct 98 ms 1004 KB Output is correct
19 Correct 72 ms 1004 KB Output is correct
20 Correct 14 ms 1004 KB Output is correct
21 Correct 14 ms 1004 KB Output is correct
22 Correct 14 ms 1004 KB Output is correct
23 Correct 15 ms 1004 KB Output is correct
24 Correct 0 ms 364 KB Output is correct
25 Correct 70 ms 1004 KB Output is correct
26 Correct 81 ms 1004 KB Output is correct
27 Correct 55 ms 1004 KB Output is correct
28 Correct 89 ms 1004 KB Output is correct
29 Correct 86 ms 1004 KB Output is correct
30 Correct 100 ms 1004 KB Output is correct