Submission #567187

# Submission time Handle Problem Language Result Execution time Memory
567187 2022-05-23T08:59:02 Z Rifal Kitchen (BOI19_kitchen) C++14
20 / 100
25 ms 1004 KB
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
const int M = 9e4 + 5;
pair<bool,int> dp[M] = {};
void add(int x)
{
    for(int i = M-1; i >= x; i--)
    {
        if(dp[i-x].first)
        {
            dp[i].first = 1;
            dp[i].second = min(dp[i].second,x);
        }

    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    int meal[n], chef[m];
    dp[0].first = 1;
    for(int i = 0; i < M; i++)
    {
        dp[i].second = INF;
    }
    long long sum = 0;
    bool ok = true;
    for(int i = 0; i < n; i++)
    {
        cin >> meal[i];
        if(meal[i] < k)
            ok = false;
        sum += meal[i];
    }
    for(int i = 0; i < m; i++)
    {
        cin >> chef[i];
        add(chef[i]);
    }
    if(m < k || ok == false)
    {
        cout << "Impossible";
        return 0;
    }

    for(int i = sum; i < M; i++)
    {
        if(dp[i].first == 1 && dp[i].second >= k && dp[i].second != INF)
        {
            cout << i-sum;
            return 0;
        }
    }

    cout << "Impossible";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Incorrect 1 ms 980 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Incorrect 1 ms 980 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1000 KB Output is correct
2 Correct 17 ms 980 KB Output is correct
3 Correct 24 ms 1000 KB Output is correct
4 Correct 25 ms 980 KB Output is correct
5 Correct 23 ms 1004 KB Output is correct
6 Correct 17 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Incorrect 1 ms 980 KB Output isn't correct
5 Halted 0 ms 0 KB -