Submission #745907

# Submission time Handle Problem Language Result Execution time Memory
745907 2023-05-21T09:32:52 Z vjudge1 Kitchen (BOI19_kitchen) C++17
0 / 100
3 ms 340 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

const ll mod = 1e9 + 7;

bool lehet[10000][400] = {false};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> v(n), t(m);
    ll sumv = 0;
    for(auto& i : v){
        cin >> i;
        sumv += i;
    }
    for(auto& i : t){
        cin >> i;
    }
    lehet[0][0] = lehet[0][t[0]] = true;
    for(int i = 1; i < m; ++i){
        for(int j = 0; j < 10000; ++j){
            lehet[i][j] |= lehet[i - 1][j];
            if(j >= t[i]){
                lehet[i][j] |= lehet[i - 1][j - t[i]];
            }
        }
    }
    ll sol = sumv;
    while(!lehet[m -1][sol] && sol < 10000) ++sol;
    if(sol == 10000){
        cout << "impossible" << endl;
    }
    else{
        cout << sol - sumv << endl;
    }
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:25:25: warning: iteration 400 invokes undefined behavior [-Waggressive-loop-optimizations]
   25 |             lehet[i][j] |= lehet[i - 1][j];
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
kitchen.cpp:24:26: note: within this loop
   24 |         for(int j = 0; j < 10000; ++j){
      |                        ~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -