답안 #928912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
928912 2024-02-17T07:57:38 Z Faisal_Saqib Kitchen (BOI19_kitchen) C++17
100 / 100
22 ms 1372 KB
#include <iostream>
using namespace std;
#define int long long
const int N=301;
int a[N],b[N],c[N];
int dp[N*N+N+N];
signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int n,m,k;
    cin>>n>>m>>k;
    int s1=0;
    int s2=n*k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<k)
        {
            cout<<"Impossible\n";
            exit(0);
        }
        s1+=a[i];
    }
    int mx=301*301;
    for(int j=0;j<=mx;j++)
        dp[j]=-1e9;
    dp[0]=0;
    int ans=-1;
    for(int j=0;j<m;j++)
    {
        cin>>b[j];
        c[j]=min(n,b[j]);
    }
    for(int j=0;j<m;j++)
    {
        for(int s3=mx-b[j];s3>=0;s3--)
        {
            dp[s3+b[j]]=max(dp[s3+b[j]],dp[s3]+c[j]);
        }
    }
    for(int s3=s1;s3<=mx;s3++)
        if(dp[s3]>=s2)
        {
            cout<<s3-s1<<'\n';
            return 0;
        }
    cout<<"Impossible\n";
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:30:9: warning: unused variable 'ans' [-Wunused-variable]
   30 |     int ans=-1;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 2 ms 1116 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Correct 2 ms 1112 KB Output is correct
12 Correct 2 ms 1116 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1116 KB Output is correct
2 Correct 16 ms 1116 KB Output is correct
3 Correct 21 ms 1184 KB Output is correct
4 Correct 21 ms 1116 KB Output is correct
5 Correct 21 ms 1372 KB Output is correct
6 Correct 16 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1112 KB Output is correct
2 Correct 4 ms 1116 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 2 ms 1116 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Correct 2 ms 1112 KB Output is correct
12 Correct 2 ms 1116 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 22 ms 1116 KB Output is correct
15 Correct 16 ms 1116 KB Output is correct
16 Correct 21 ms 1184 KB Output is correct
17 Correct 21 ms 1116 KB Output is correct
18 Correct 21 ms 1372 KB Output is correct
19 Correct 16 ms 1112 KB Output is correct
20 Correct 3 ms 1112 KB Output is correct
21 Correct 4 ms 1116 KB Output is correct
22 Correct 5 ms 1372 KB Output is correct
23 Correct 3 ms 1116 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 17 ms 1116 KB Output is correct
26 Correct 18 ms 1176 KB Output is correct
27 Correct 11 ms 1116 KB Output is correct
28 Correct 17 ms 1160 KB Output is correct
29 Correct 18 ms 1116 KB Output is correct
30 Correct 21 ms 1116 KB Output is correct