Submission #928775

#TimeUsernameProblemLanguageResultExecution timeMemory
928775Sir_Ahmed_ImranKitchen (BOI19_kitchen)C++17
72 / 100
197 ms262144 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define append push_back #define add insert #define nl "\n" #define ff first #define ss second #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL) #define N 90001 #define M 89701 bitset<M> dp[N]; void solve(){ int n,m,o,p,q,r; bitset<M> tmp; cin>>n>>m>>o; dp[0][0]=1; r=0; for(int i=0;i<n;i++){ cin>>p; r+=p; if(p<o){ cout<<"Impossible"; return; } } r-=n*o; for(int i=0;i<m;i++){ cin>>p; q=max(0,p-n); p-=q; for(int j=n*o;j>=0;j--){ tmp=dp[j]; tmp<<=(q+max(0,p+j-n*o)); dp[min(j+p,n*o)]|=tmp; } } for(int i=0;r+i<N;i++){ if(dp[n*o][r+i]){ cout<<i; return; } } cout<<"Impossible"; } int main(){ L0TA; solve(); return 0; }
#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...