Submission #320915

#TimeUsernameProblemLanguageResultExecution timeMemory
320915kimbj0709Kitchen (BOI19_kitchen)C++14
100 / 100
100 ms1152 KiB
#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 (stderr)

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;
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...