# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014616 | 2024-07-05T08:05:14 Z | vjudge1 | Kitchen (BOI19_kitchen) | C++17 | 171 ms | 225580 KB |
#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]; if(dish[i]<k) { cout << "Impossible" << endl; return 0; } } for(int i = 1; i <=m; i++){ cin >> chef[i]; sum +=chef[i]; } ll dp[m+1][sum+1]; bool found[m+1][sum+1]; memset(dp,0,sizeof(dp)); memset(found,0,sizeof(found)); dp[0][0]=0; found[0][0]=1; for(int i =1; i <= m; i++){ for(int j = 0; j<=sum; j++){ dp[i][j] = dp[i-1][j]; found[i][j] = found[i-1][j]; if(j>=chef[i]&& found[i-1][j-chef[i]] ){ dp[i][j] = max(dp[i][j], dp[i-1][j-chef[i]]+ min(chef[i], n)); found[i][j]=1; } } } for(int i = target; i <= sum; i++){ // cout <<dp[m][i]<<" "<< i << endl; if(dp[m][i]>=n*k){ cout << i-target << endl; return 0; } } cout << "Impossible" << endl; } /* 6 1 1 1 3 2 3 3 4 6 4 4 5 4 1 3 2 5 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 2 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 2 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
9 | Correct | 2 ms | 3164 KB | Output is correct |
10 | Correct | 1 ms | 3164 KB | Output is correct |
11 | Correct | 1 ms | 2600 KB | Output is correct |
12 | Correct | 1 ms | 2608 KB | Output is correct |
13 | Correct | 2 ms | 3164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 154824 KB | Output is correct |
2 | Correct | 70 ms | 116052 KB | Output is correct |
3 | Correct | 91 ms | 129876 KB | Output is correct |
4 | Correct | 157 ms | 221256 KB | Output is correct |
5 | Correct | 171 ms | 221780 KB | Output is correct |
6 | Correct | 67 ms | 94804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3164 KB | Output is correct |
2 | Correct | 1 ms | 2908 KB | Output is correct |
3 | Correct | 2 ms | 3164 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 2 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
9 | Correct | 2 ms | 3164 KB | Output is correct |
10 | Correct | 1 ms | 3164 KB | Output is correct |
11 | Correct | 1 ms | 2600 KB | Output is correct |
12 | Correct | 1 ms | 2608 KB | Output is correct |
13 | Correct | 2 ms | 3164 KB | Output is correct |
14 | Correct | 92 ms | 154824 KB | Output is correct |
15 | Correct | 70 ms | 116052 KB | Output is correct |
16 | Correct | 91 ms | 129876 KB | Output is correct |
17 | Correct | 157 ms | 221256 KB | Output is correct |
18 | Correct | 171 ms | 221780 KB | Output is correct |
19 | Correct | 67 ms | 94804 KB | Output is correct |
20 | Correct | 2 ms | 3164 KB | Output is correct |
21 | Correct | 1 ms | 2908 KB | Output is correct |
22 | Correct | 2 ms | 3164 KB | Output is correct |
23 | Correct | 2 ms | 3164 KB | Output is correct |
24 | Correct | 1 ms | 2652 KB | Output is correct |
25 | Correct | 80 ms | 113748 KB | Output is correct |
26 | Correct | 106 ms | 140372 KB | Output is correct |
27 | Correct | 32 ms | 43356 KB | Output is correct |
28 | Correct | 84 ms | 115352 KB | Output is correct |
29 | Correct | 112 ms | 157520 KB | Output is correct |
30 | Correct | 163 ms | 225580 KB | Output is correct |