Submission #464464

# Submission time Handle Problem Language Result Execution time Memory
464464 2021-08-13T09:06:36 Z BT21tata Kitchen (BOI19_kitchen) C++17
20 / 100
58 ms 372 KB
#include<bits/stdc++.h>
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
using namespace std;
//mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
 
int n, m, k, a[305], b[305];
int suma, sumb;
bool dp[100005];
int main()
{
    SPEED;
    cin>>n>>m>>k;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0; i<m; i++)
    {
        cin>>b[i];
        sumb+=b[i];
    }
    if(sumb<suma) cout<<"Impossible\n";
    dp[0]=1;
    for(int i=0; i<m; i++)
        for(int j=100000; j>=0; j--)
            if(dp[j])
            {
                dp[j+b[i]]=1;
            }

    for(int i=suma; i<=100000; i++)
        if(dp[i]) return cout<<i-suma<<endl,0;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 360 KB Output is correct
2 Correct 28 ms 364 KB Output is correct
3 Correct 56 ms 332 KB Output is correct
4 Correct 58 ms 364 KB Output is correct
5 Correct 52 ms 372 KB Output is correct
6 Correct 26 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -