Submission #1083526

#TimeUsernameProblemLanguageResultExecution timeMemory
1083526browntoadKitchen (BOI19_kitchen)C++14
21 / 100
59 ms95316 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long // #define int ll #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, n+1) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define RREP1(i, n) for (int i = (n); i >= 1; i--) #define pii pair<int, int> #define ppi pair<pii, int> #define pip pair<int, pii> #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #define f first #define s second #define pb push_back #define endl '\n' #define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) const ll maxn = 305; const ll mod = 1e9+7; const ll inf = 1ll<<60; ll mpw(ll a, ll p, ll m = mod){ ll ret = 1; while(p > 0){ if (p & 1){ ret *= a; ret %= m; } p >>= 1; a *= a; a %= m; } return ret; } ll inv(ll a){ return mpw(a, mod-2); } int n, m, k; int dp[maxn][maxn*maxn]; signed main(){ IOS(); cin>>n>>m>>k; int tot = 0; REP(i, n){ int tt; cin>>tt; tot += tt; if (tt < k){ cout<<"Impossible"<<endl; return 0; } } REP1(i, m){ int b; cin>>b; REP(j, maxn*maxn){ dp[i][j] = dp[i-1][j]; if (j >= b) dp[i][j] = max(dp[i][j], dp[i-1][j-b] + min(b, n)); } } int ret = -1; FOR(i, tot, maxn*maxn){ if (dp[m][i] >= n*k){ ret = i; break; } } if (ret == -1) cout<<"Impossible"<<endl; else { cout<<ret-tot<<endl; } }
#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...