Submission #725976

# Submission time Handle Problem Language Result Execution time Memory
725976 2023-04-18T09:35:53 Z fdnfksd Kitchen (BOI19_kitchen) C++14
21 / 100
23 ms 1748 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=300*300+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll dp[2][maxN];
ll n,m,a[maxN],b[maxN];
ll k,sum=0;
void solve()
{
    cin >> n >> m >> k;
    for(int i=1;i<=n;i++) cin >> a[i],sum+=a[i];
    for(int i=1;i<=m;i++) cin >> b[i];
    dp[0][0]=0;
    for(int i=1;i<=n;i++) if(a[i]<k) {cout << "Impossible";return;}
    for(int i=1;i<maxN;i++) dp[0][i]=-inf;
    for(int i=1;i<=m;i++)
    {
        for(int j=b[i];j<maxN;j++)
        {
            ll cc=min(b[i],n);
            dp[i&1][j]=max(dp[(i-1)&1][j],dp[(i-1)&1][j-b[i]]+cc);
        }
    }
    for(int i=sum;i<maxN;i++)
    {
        if(dp[m&1][i]>=n*k)
        {
            cout << i-sum;
            return;
        }
    }
    {cout << "Impossible";return;}
}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1740 KB Output is correct
2 Correct 6 ms 1748 KB Output is correct
3 Correct 8 ms 1740 KB Output is correct
4 Correct 6 ms 1748 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -