Submission #204156

# Submission time Handle Problem Language Result Execution time Memory
204156 2020-02-24T16:45:42 Z Rouge_Hugo Kitchen (BOI19_kitchen) C++14
100 / 100
44 ms 1816 KB
        #include<bits/stdc++.h>
        #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        #define ll long long
        using namespace std;
        ll n,m,k;
        const int inf=1e14;
        const int N=309;
        ll d[2][N*N],c[N],b[N],a[N];
        int g (int x)
        {
            return x%2;
        }
        int go (int i)
        {
            if (d[g(m-1)][i]>=n*k)return 1;
            return 0;
        }
        int main()
        {
            cin>>n>>m>>k;ll s=0;
            for(int i=0;i<n;i++){cin>>a[i];if (a[i]<k){cout<<"Impossible";return 0;}s+=a[i];}
            for(int i=0;i<m;i++){cin>>b[i];c[i]=min(b[i],n);}

            for(int j=0;j<90009;j++)d[0][j]=-inf,d[1][j]=-inf;d[0][0]=0;
            d[0][b[0]]=c[0];
            for(int i=1;i<m;i++)
            {
                for(int j=0;j<=90009;j++)
                {
                    d[g(i)][j]=d[g(i-1)][j];
                    if (j-b[i]<0)continue;
                    d[g(i)][j]=max(d[g(i)][j],d[g(i-1)][j-b[i]]+c[i]);
                }
            }
            for(int i=s;i<=90009;i++)
            if (go(i))
            {
                cout<<i-s;return 0;
            }
            cout<<"Impossible";
        }

Compilation message

kitchen.cpp:6:23: warning: overflow in implicit constant conversion [-Woverflow]
         const int inf=1e14;
                       ^~~~
kitchen.cpp: In function 'int main()':
kitchen.cpp:24:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
             for(int j=0;j<90009;j++)d[0][j]=-inf,d[1][j]=-inf;d[0][0]=0;
             ^~~
kitchen.cpp:24:63: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             for(int j=0;j<90009;j++)d[0][j]=-inf,d[1][j]=-inf;d[0][0]=0;
                                                               ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1784 KB Output is correct
2 Correct 6 ms 1784 KB Output is correct
3 Correct 6 ms 1784 KB Output is correct
4 Correct 7 ms 1656 KB Output is correct
5 Correct 6 ms 1784 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 6 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1784 KB Output is correct
2 Correct 6 ms 1784 KB Output is correct
3 Correct 6 ms 1784 KB Output is correct
4 Correct 7 ms 1656 KB Output is correct
5 Correct 6 ms 1784 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 6 ms 1784 KB Output is correct
9 Correct 7 ms 1784 KB Output is correct
10 Correct 7 ms 1784 KB Output is correct
11 Correct 8 ms 1784 KB Output is correct
12 Correct 7 ms 1784 KB Output is correct
13 Correct 7 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1816 KB Output is correct
2 Correct 34 ms 1784 KB Output is correct
3 Correct 44 ms 1784 KB Output is correct
4 Correct 43 ms 1784 KB Output is correct
5 Correct 41 ms 1784 KB Output is correct
6 Correct 31 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1784 KB Output is correct
2 Correct 10 ms 1784 KB Output is correct
3 Correct 11 ms 1784 KB Output is correct
4 Correct 11 ms 1784 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1784 KB Output is correct
2 Correct 6 ms 1784 KB Output is correct
3 Correct 6 ms 1784 KB Output is correct
4 Correct 7 ms 1656 KB Output is correct
5 Correct 6 ms 1784 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 6 ms 1784 KB Output is correct
9 Correct 7 ms 1784 KB Output is correct
10 Correct 7 ms 1784 KB Output is correct
11 Correct 8 ms 1784 KB Output is correct
12 Correct 7 ms 1784 KB Output is correct
13 Correct 7 ms 1784 KB Output is correct
14 Correct 38 ms 1816 KB Output is correct
15 Correct 34 ms 1784 KB Output is correct
16 Correct 44 ms 1784 KB Output is correct
17 Correct 43 ms 1784 KB Output is correct
18 Correct 41 ms 1784 KB Output is correct
19 Correct 31 ms 1784 KB Output is correct
20 Correct 11 ms 1784 KB Output is correct
21 Correct 10 ms 1784 KB Output is correct
22 Correct 11 ms 1784 KB Output is correct
23 Correct 11 ms 1784 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 32 ms 1784 KB Output is correct
26 Correct 36 ms 1784 KB Output is correct
27 Correct 26 ms 1784 KB Output is correct
28 Correct 36 ms 1784 KB Output is correct
29 Correct 36 ms 1784 KB Output is correct
30 Correct 44 ms 1784 KB Output is correct