Submission #1014581

#TimeUsernameProblemLanguageResultExecution timeMemory
1014581Error404Kitchen (BOI19_kitchen)C++17
0 / 100
20 ms20312 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define f first #define s second #define pi pair<ll,ll> #define vi vector<ll> #define vd vector<double> #define vpi vector<pi> #define pb push_back #define INF 1e18 #define endl '\n' //#define int ll #define pii pair<pi,ll> const int mod = 1e9+7; const int MAX = 1e5+1; const int LOG = 30; vi g[MAX]; int tin[MAX], val[MAX], tout[MAX]; int up[LOG+1][MAX]; map<pi,int>mp; vector<pi>order; int timer = 0; signed main(){ int n,m,k,a,b; cin >>n >> m >> k; int dish[n+1], chef[m+1]; ll sum = 0, target = 0;; for(int i= 1; i<= n; i++){ cin >> dish[i]; target += dish[i]; } for(int i = 1; i <=m; i++){ cin >> chef[i]; sum +=chef[i]; } bool dp[m+1][sum+1]; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i =1; i <= m; i++){ for(int j = 0; j<=sum; j++){ if(j>=chef[i]&&dp[i-1][j-chef[i]]) dp[i][j] = 1; } } for(int i = target; i <= sum; i++){ if(dp[m][i]){ cout << i-target << endl; return 0; } } cout << "Impossible" << endl; }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:30:15: warning: unused variable 'a' [-Wunused-variable]
   30 |     int n,m,k,a,b;
      |               ^
kitchen.cpp:30:17: warning: unused variable 'b' [-Wunused-variable]
   30 |     int n,m,k,a,b;
      |                 ^
#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...