Submission #1128169

#TimeUsernameProblemLanguageResultExecution timeMemory
1128169akhmed은행 (IZhO14_bank)C++20
0 / 100
1 ms836 KiB
//#include <bits/stdc++.h>

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <random>

using namespace std;
using ll = long long;

#define int long long

const int N = 3e5 + 7;
const int M = 1e9 + 7, MX = 1e18 + 7;

struct custom_hash { //unordered_map<long long, int, custom_hash> safe_map; gp_hash_table<long long, int, custom_hash> safe_hash_table;

    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

inline int binpow(int a, int n, int m) {
    int res = 1;
    while (n) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

inline int gcd(int a, int b) {
    while (b != 0) {
        a = a % b;
        swap(a, b);
    }
    return a;
}

//int f[N], invf[N];
//
//inline void factorials(int n) {
//    f[0] = 1;
//    for(int i = 1; i <= n; i++) {
//        f[i] = (f[i - 1] * i) % M;
//    }
//    invf[n] = binpow(f[n], M - 2, M);
//    for(int i = n - 1; i >= 0; i--) {
//        invf[i] = (invf[i + 1] * (i + 1)) % M;
//    }
//}
//
//inline int cnk(int n, int k) {
//    if(k > n) {
//        return 0;
//    }
//    return (((f[n] * invf[n - k]) % M) * invf[k]) % M;
//}

int dp[23][23][23][23], a[23], b[23];

inline void Solve() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= m; i++) cin >> b[i];
    for(int it = 1; it <= m; it++) {
        for(int i = 0; i <= n; i++) {
            for(int j = 0; j <= n; j++) {
                for(int jj = 0; jj <= n; jj++) {
                    int yes = 0;
                    for(int k = 1; k <= n; k++) {
                        dp[it][i][j][k] = dp[it - 1][j][jj][k];
                        if(i == k) {
                            dp[it][i][j][k] += b[i];
                        }
                        if(dp[it][i][j][k] == a[k]) yes++;
                    }
                    if(yes == n) {
                        cout << "YES\n";
                        return;
                    }
                }
            }
        }
    }
    cout << "NO\n";
}
 
signed main() {
    //freopen("bank.in", "r", stdin);
    //freopen("bank.out", "w", stdout);
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cout.tie(nullptr);
    
    int t = 1;
//    cin >> t;
    cout << '\n' << '\n';
    
    while(t--) {
        Solve();
    }
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...