답안 #725981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725981 2023-04-18T09:37:58 Z fdnfksd Kitchen (BOI19_kitchen) C++14
100 / 100
119 ms 1824 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 j=0;j<b[i];j++)
        {
            dp[i&1][j]=dp[(i-1)&1][j];
        }
    }
    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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1620 KB Output is correct
2 Correct 1 ms 1736 KB Output is correct
3 Correct 2 ms 1620 KB Output is correct
4 Correct 2 ms 1732 KB Output is correct
5 Correct 2 ms 1732 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 3 ms 232 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1620 KB Output is correct
2 Correct 1 ms 1736 KB Output is correct
3 Correct 2 ms 1620 KB Output is correct
4 Correct 2 ms 1732 KB Output is correct
5 Correct 2 ms 1732 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 3 ms 232 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 9 ms 1736 KB Output is correct
11 Correct 3 ms 1740 KB Output is correct
12 Correct 4 ms 1732 KB Output is correct
13 Correct 4 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1740 KB Output is correct
2 Correct 28 ms 1732 KB Output is correct
3 Correct 36 ms 1732 KB Output is correct
4 Correct 29 ms 1728 KB Output is correct
5 Correct 119 ms 1728 KB Output is correct
6 Correct 24 ms 1736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1824 KB Output is correct
2 Correct 5 ms 1620 KB Output is correct
3 Correct 6 ms 1620 KB Output is correct
4 Correct 6 ms 1736 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1620 KB Output is correct
2 Correct 1 ms 1736 KB Output is correct
3 Correct 2 ms 1620 KB Output is correct
4 Correct 2 ms 1732 KB Output is correct
5 Correct 2 ms 1732 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 3 ms 232 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 9 ms 1736 KB Output is correct
11 Correct 3 ms 1740 KB Output is correct
12 Correct 4 ms 1732 KB Output is correct
13 Correct 4 ms 1748 KB Output is correct
14 Correct 25 ms 1740 KB Output is correct
15 Correct 28 ms 1732 KB Output is correct
16 Correct 36 ms 1732 KB Output is correct
17 Correct 29 ms 1728 KB Output is correct
18 Correct 119 ms 1728 KB Output is correct
19 Correct 24 ms 1736 KB Output is correct
20 Correct 7 ms 1824 KB Output is correct
21 Correct 5 ms 1620 KB Output is correct
22 Correct 6 ms 1620 KB Output is correct
23 Correct 6 ms 1736 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 25 ms 1620 KB Output is correct
26 Correct 26 ms 1724 KB Output is correct
27 Correct 18 ms 1620 KB Output is correct
28 Correct 28 ms 1760 KB Output is correct
29 Correct 32 ms 1620 KB Output is correct
30 Correct 37 ms 1652 KB Output is correct