Submission #1209420

#TimeUsernameProblemLanguageResultExecution timeMemory
1209420Theo830Kitchen (BOI19_kitchen)C++20
31 / 100
8 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training int main(void){ ll n,m,k; cin>>n>>m>>k; ll a[n]; f(i,0,n){ cin>>a[i]; } ll b[m]; f(i,0,m){ cin>>b[i]; } ll ans = 1e18; f(i,0,(1<<m)){ ll posa = 0; ll sumi = 0; f(j,0,m){ if(i & (1<<j)){ posa += min(n,b[j]); sumi += b[j]; } } f(j,0,n){ if(a[j] < k){ posa = 0; } sumi -= a[j]; } if(sumi < 0){ posa = 0; } if(posa >= n * k){ ans = min(ans,sumi); } } if(ans != (ll)1e18){ cout<<ans<<"\n"; } else{ cout<<"Impossible\n"; } }
#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...