답안 #942633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942633 2024-03-11T01:58:44 Z damwuan Kitchen (BOI19_kitchen) C++17
0 / 100
54 ms 93016 KB



#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define bit(n,i) ((n>>i)&1)
#define all(x) x.begin(),x.end()
//#pragma GCC optimize("O2,unroll-loops")
//#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,ssse3,sse4,popcnt")
//#define int long long
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef pair<db,db> pdd;
typedef pair<ll,ll> pll;
const ll maxn=300;
const ll maxk=2e5+5;
const ll block_sz=317;
const ll inf=1e9;
const ll mod=111539786;

int n,m,k,a[maxn],b[maxn],sum;
vector<vector<int>> dp;
void sol()
{
    cin >> n>>m>>k;
    for1(i,1,n) cin >> a[i];
    for1(i,1,m) cin >> b[i];
    if (k>m)
    {
        cout << "Impossible";
        return;
    }

    for1(i,1,n)
    {
        if (a[i]< k)
        {
            cout << "Impossible";
            return;
        }
        sum+=(a[i]-k);
    }
//    return;
    dp.resize(m+1,vector<int>(300*300+1,-inf));
    dp[0][0]=0;
    for1(i,1,m)
    {
        for1(j,0,300*300)
        {
            if (b[i]>=n)
            {
                dp[i][j]=dp[i-1][j];
                if (j-b[i]+n>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-b[i]+n]+n);
            }
            else dp[i][j]=dp[i-1][j]+b[i];
        }
    }
//    cerr<<m<<' '<<sum<<' '<< dp[m][sum]<<'\n';
    for1(i,sum,300*300)
    {
        if (dp[m][i] >= n*k)
        {
            cout << i-sum<<'\n';
            return;
        }
    }
    cout << "Impossible\n";

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("RECTANGLE.inp","r",stdin);
//    freopen("RECTANGLE.out","w",stdout);

    int t=1;//cin >> t;
    while (t--)
    {
        sol();
    }
}
/*

C[i-1][i+j-1]*C[sz[u]-i][sz[u]+sz[v]-i]
*/







# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Incorrect 2 ms 1628 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Incorrect 2 ms 1628 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 93016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 15196 KB Output is correct
2 Correct 15 ms 15196 KB Output is correct
3 Incorrect 10 ms 15192 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Incorrect 2 ms 1628 KB Output isn't correct
4 Halted 0 ms 0 KB -