Submission #676915

# Submission time Handle Problem Language Result Execution time Memory
676915 2023-01-01T15:07:18 Z thegamercoder19 Bank (IZhO14_bank) C++14
25 / 100
102 ms 262144 KB
/*
Coded by thegamercoder19
GL
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ll MAX = 25;
const ll S = 1e5;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout<<(s?"YES":"NO")<<endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP 0
using namespace std;
ll n, m;
V<ll> a, b;
V<V<ll>> dp;
bool chk(ll msk, ll i, ll x)
{
    if (i == -1)return 1;
    if (!x) return chk(msk, i - 1, a[i-1]);
    if (!msk || x<0)return 0;
    if (dp[msk][x] != -1)
        return dp[msk][x];
    bool res = 0;
    FOR(ll, j, 0, m, 1)
        if (((1 << j) & msk) && x>=b[j])
            res = res || chk(msk ^ (1 << j), i, x - b[j]);
    return dp[msk][x] = res;
}

void solve() {
    cin >> n >> m;
    a.resize(n); b.resize(m); dp.resize((1 << m), V<ll>(10001,-1));
    FOR(ll, i, 0, n, 1)cin >> a[i];
    FOR(ll, i, 0, m, 1)cin >> b[i];
    YESNO(chk((1 << m) - 1, n - 1, a[n - 1]));
}
void init()
{

    if (FILER)
    {
        freopen("movie.in", "r", stdin);
        freopen("movie.out", "w", stdout);
    }
}

void handle()
{
    init();
    ll t = 1;
    if (TYP)cin >> t;

    WHI(t)solve();
}

int main()
{
    IOF
        handle();
    RET 0;
}

Compilation message

bank.cpp: In function 'bool chk(ll, ll, ll)':
bank.cpp:63:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   63 |     return dp[msk][x] = res;
bank.cpp: In function 'void init()':
bank.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen("movie.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen("movie.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2900 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 32 ms 80540 KB Output is correct
4 Runtime error 98 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 80536 KB Output is correct
2 Correct 37 ms 80600 KB Output is correct
3 Correct 35 ms 80468 KB Output is correct
4 Correct 34 ms 80468 KB Output is correct
5 Correct 33 ms 80540 KB Output is correct
6 Correct 31 ms 80508 KB Output is correct
7 Correct 32 ms 80472 KB Output is correct
8 Correct 35 ms 80536 KB Output is correct
9 Correct 33 ms 80468 KB Output is correct
10 Correct 39 ms 80512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2900 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 32 ms 80540 KB Output is correct
4 Runtime error 98 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -