Submission #644487

#TimeUsernameProblemLanguageResultExecution timeMemory
644487amoorjKitchen (BOI19_kitchen)C++17
0 / 100
163 ms221252 KiB
//#pragma GCC optimize ("O3,unroll-loops,Ofast") //#pragma GCC target ("avx2,bmi,bmi2,popcnt") #include <bits/stdc++.h> #define F first #define pb push_back #define sz size() #define S second using namespace std; typedef long long int ll; const int N = 303, INF = 2e9; int n,k,m,a[N],b[N],dp[N][N*N],sum = 0; inline void init(){ for(int i=0;i<N;i++) for(int j=0;j<N*N;j++) dp[i][j] = -INF; } inline void input(){ cin >> n >> m >> k; for(int i=0;i<n;i++){ cin >> a[i]; sum += a[i]; } for(int i=0;i<m;i++) cin >> b[i]; } inline void solve(){ dp[0][0] = 0; for(int i=0;i<m;i++){ for(int j=0;j<N*N;j++){ dp[i+1][j] = dp[i][j]; if(j >= b[i]) dp[i+1][j] = max(dp[i+1][j], dp[i][j-b[i]] + min(b[i], n)); } } for(int i=0;i<n;i++){ if(a[i] < k){ cout << "Impossible"; return; } } for(int j=0;j<N*N;j++){ if(dp[m][j] >= n*k){ cout << j - sum; if(j - sum < 0) assert(false); return; } } cout << "Impossible"; } int main(){ ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); init(); int queries = 1; // cin >> queries; while(queries--){ input(); 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...