답안 #928886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
928886 2024-02-17T07:35:25 Z Muhammad_Aneeq Kitchen (BOI19_kitchen) C++17
100 / 100
29 ms 856 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/

#include <iostream>
using namespace std;
int const N=300*300+10;
int sums[N]={};
inline void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    int z=0;
    int a[n];
    for (auto& i:a)
    {
        cin>>i,z+=i;
        if (i<k)
        {
            cout<<"Impossible\n";return;
        }
    }
    for (int i=0;i<N-1;i++)
        sums[i]=-1e9+10;
    sums[0]=0;
    int ans=1e9+10;
    int f=k*n;
    for (int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        for (int j=N-x-1;j>=0;j--)
        {
            sums[j+x]=max(sums[j+x],sums[j]+min(x,n));
            if (sums[j+x]>=f&&j+x>=z)
                ans=min(ans,j+x-z);
        }
    }
    if (ans==1e9+10)
        cout<<"Impossible\n";
    else
        cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 808 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 808 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 600 KB Output is correct
2 Correct 22 ms 604 KB Output is correct
3 Correct 29 ms 812 KB Output is correct
4 Correct 27 ms 604 KB Output is correct
5 Correct 25 ms 604 KB Output is correct
6 Correct 21 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 604 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 5 ms 604 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 808 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 25 ms 600 KB Output is correct
15 Correct 22 ms 604 KB Output is correct
16 Correct 29 ms 812 KB Output is correct
17 Correct 27 ms 604 KB Output is correct
18 Correct 25 ms 604 KB Output is correct
19 Correct 21 ms 600 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 5 ms 604 KB Output is correct
22 Correct 5 ms 604 KB Output is correct
23 Correct 5 ms 604 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 21 ms 808 KB Output is correct
26 Correct 24 ms 604 KB Output is correct
27 Correct 17 ms 600 KB Output is correct
28 Correct 26 ms 604 KB Output is correct
29 Correct 24 ms 856 KB Output is correct
30 Correct 27 ms 604 KB Output is correct