Submission #888786

# Submission time Handle Problem Language Result Execution time Memory
888786 2023-12-18T07:48:47 Z 12345678 Kitchen (BOI19_kitchen) C++17
100 / 100
62 ms 111360 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=305;
int n, m, k, sm, x, dp[nx][nx*nx], c, ans=INT_MAX;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m>>k;
    for (int i=1; i<=n; i++) cin>>x, sm+=x, c|=(x<k);
    for (int i=0; i<=n; i++) for (int j=1; j<nx*nx; j++) dp[i][j]=INT_MIN;
    for (int i=1; i<=m; i++)
    {
        cin>>x;
        for (int j=0; j<nx*nx; j++) dp[i][j]=dp[i-1][j];
        for (int j=0; j+x<nx*nx; j++)
        {
            dp[i][j+x]=max(dp[i][j+x], dp[i-1][j]+min(x, n));
            if (dp[i][j+x]>=n*k&&j+x>=sm) ans=min(ans, j+x-sm);
        }
        //for (int j=0; j<20; j++) cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
    }
    if (ans==INT_MAX||c) cout<<"Impossible";
    else cout<<ans;
}
# 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 4952 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 23 ms 111224 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 4700 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 4952 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 23 ms 111224 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 3 ms 6748 KB Output is correct
11 Correct 4 ms 6608 KB Output is correct
12 Correct 6 ms 12892 KB Output is correct
13 Correct 22 ms 111252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 109148 KB Output is correct
2 Correct 50 ms 109148 KB Output is correct
3 Correct 62 ms 111188 KB Output is correct
4 Correct 59 ms 111360 KB Output is correct
5 Correct 58 ms 111196 KB Output is correct
6 Correct 47 ms 109224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 16984 KB Output is correct
2 Correct 8 ms 16984 KB Output is correct
3 Correct 8 ms 17064 KB Output is correct
4 Correct 8 ms 16988 KB Output is correct
5 Correct 8 ms 16988 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 4952 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 23 ms 111224 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 3 ms 6748 KB Output is correct
11 Correct 4 ms 6608 KB Output is correct
12 Correct 6 ms 12892 KB Output is correct
13 Correct 22 ms 111252 KB Output is correct
14 Correct 54 ms 109148 KB Output is correct
15 Correct 50 ms 109148 KB Output is correct
16 Correct 62 ms 111188 KB Output is correct
17 Correct 59 ms 111360 KB Output is correct
18 Correct 58 ms 111196 KB Output is correct
19 Correct 47 ms 109224 KB Output is correct
20 Correct 8 ms 16984 KB Output is correct
21 Correct 8 ms 16984 KB Output is correct
22 Correct 8 ms 17064 KB Output is correct
23 Correct 8 ms 16988 KB Output is correct
24 Correct 8 ms 16988 KB Output is correct
25 Correct 41 ms 78584 KB Output is correct
26 Correct 46 ms 90708 KB Output is correct
27 Correct 31 ms 59872 KB Output is correct
28 Correct 47 ms 90704 KB Output is correct
29 Correct 47 ms 93144 KB Output is correct
30 Correct 58 ms 111188 KB Output is correct