제출 #945977

#제출 시각아이디문제언어결과실행 시간메모리
945977iaraha은행 (IZhO14_bank)C++14
71 / 100
1034 ms93300 KiB
// Эксперт до 15.04.2024 Насиб
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pf push_front
#define pof pop_front
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define Yes cout << "YES \n"
#define No cout << "NO \n"
#define Ferarri ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
//////////////////// the code below ////////////////////
bool dp[(1 << 21) + 5][25] = {};
signed main(){
    Ferarri
    ll t = 1;
    //cin >> t;
    //cout << setprecision(8) << fixed;
    while (t --) {
        ll n, m;
        cin >> n >> m;
        ll a[n], b[m];
        vector<ll>w[n + 5];
        vector<ll> can[n + 5];
        map<ll, ll>mp;
        for (ll i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (ll i = 0; i < m; i++) {
            cin >> b[i];
        }
        for (ll i = 0; i < (1 << m); i++) {
            ll s = 0;
            for (ll j = 0; j < m; j++) {
                if (i & (1 << (m - j - 1))) {
                    s += b[j];
                }
            }
            mp[i] = s;
        }
        bool chk = 0;
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < (1 << m); j++) {
                if (mp[j] == a[i]) {
                    w[i].pb(j);
                    if (i == 0) {
                        can[0].push_back(j);
                        dp[j][i] = 1;
                        if (n == 1) chk = 1;
                    }
                }
            }
        }
        for (ll i = 1; i < n; i++) {
            for (ll j = 0; j < w[i].size(); j++) {
                for (ll k = 0; k < can[i - 1].size(); k++) {
                    if (!(w[i][j] & can[i - 1][k]) && !dp[w[i][j] + can[i - 1][k]][i]) {
                        dp[w[i][j] + can[i - 1][k]][i] = 1;
                        can[i].push_back(w[i][j] + can[i - 1][k]);
                        if (i == n - 1)
                            chk = 1;
                    }
                }
            }
        }
        if (chk) Yes;
        else No;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:59:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             for (ll j = 0; j < w[i].size(); j++) {
      |                            ~~^~~~~~~~~~~~~
bank.cpp:60:34: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |                 for (ll k = 0; k < can[i - 1].size(); k++) {
      |                                ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...