Submission #1107297

#TimeUsernameProblemLanguageResultExecution timeMemory
1107297vjudge1Bank (IZhO14_bank)C++17
46 / 100
1 ms504 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; #define pb push_back #define int long long #define no "NO\n" #define yes "YES\n" #define ew "\n" #define all(x) x.begin(), x.end() #define F first #define S second #define float long double #define len(x) (int)x.size() #define macvin \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using pii = pair<int, int>; using ld = long double; const int N = 2e6 + 7; const int mod = 1e9 + 7; const int inf = 1e18 + 7; const int hh = 1e2 + 70; const int MAX = 200007; const int maxn = 1e6 + 7; int n, q; int used[N]; int t[N * 4]; bool ARMANABIKRASH(vector<int> a, vector<int> b) { int mx = *max_element(all(b)); vector<bool> dp(mx + 1, 0); dp[0] = 1; for (int to : a) { for (int j = mx; j >= to; j--) { dp[j] = dp[j] || dp[j - to]; } } for (int to : b) { if (to > mx || !dp[to]) { return 0; } } return 1; } void iamgoingto10of10() { cin >> n >> q; vector<int> a(n), b(q); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < q; i++) { cin >> b[i]; } if (ARMANABIKRASH(b, a)) { cout << yes; } else { cout << no; } } signed main() { macvin int T = 1; // cin >> T; while (T--) { iamgoingto10of10(); } } /* ⣿⣿⣿⣿⣿⣿⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣤⠤⠤⠀⠒⠶⣀⠀⠀⠀⠈⣿⣿⣿⡿⠁ ⣿⣿⣿⣿⣿⡗⠈⠀⠀⠀⣠⢀⣀⠀⣀⠀⢀⡀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠶⠚⣛⣉⠠⠀⣄⣀⠀⠀⠀⠀⠀⠀⠀⢿⣿⡿⠁⠀ ⠃⠀⠀ ⠀⣿⣼⡟⣿⣿⠀⢀⠢⠁⠀⣰⣜⣿⢿⣿⠿⢿⠟⢕⠢⠀⠃⠀⠀⠀⠀⠀⠀⠀⠐⠁⠈⠒⠒⠁⠀⠈⠅⠀⠀⠀⠀⠀⠀⡘⠟⢀⠀⠀ ⠲⣿⢧⡃⣽⣿⠂⠀⠀⠀⠀⠉⠟⠉⠠⠈⠁⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠺⠀⠀⠀⠀ ⠀⡹⠸⣇⢸⣿⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠆⠀⠀⠀ ⢠⡇⠀⣿⡘⢿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀ ⣼⣯⡈⠈⢯⠎⠻⡜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀ ⣿⣷⣿⣆⢘⣆⠀⣷⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣷⠮⠁⠀⠀ ⣿⣿⣿⣿⣶⣌⠦⣜⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⣀⡄⠀⠀⠀⣰⣤⡠⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⢋⠄⠀⢀⢠ ⣿⣿⣿⣿⣿⣿⣷⣎⣗⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢛⠙⠛⡈⠀⠜⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡂⢠⡴⣏⢧ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣷⢿⡱⣏⠖ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠠⢤⣤⣤⣤⣄⣀⣠⣀⣠⠶⠴⠦⠤⠒⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡿⣏⠷⠈⠌ ⠀⠌⠙⠻⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢺⠟⠀⠀⠀⠀ ⠀⠀⠀⠀⢉⠻⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠀⡈⠇⠀⠀⠀⠀ ⠀⠀⠀⠀⠈⠉⠙⠻⢿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠔⠇⢠⠃⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣦⡀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠁⠀⢠⠎⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⢹⣿⣞⡄⡀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠎⠀⠀⣀⠔⠁⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣈⢻⣿⣧⣗⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⢖⡡⠔⣠⡰⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣼⣿⡏⠈⣿⡿⠁⠀⠀⠽⢿⣿⣾⣽⡷⣦⢤⡀⡄⣀⠀⡀⡀⠄⠔⣒⢱⣜⣮⡴⠚⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⣾⣿⣿⡇⠀⢿⠁⠀⠀⠀⠀⠈⠙⣿⣿⣿⣿⣯⣷⡬⣫⡀⡱⣀⣖⣼⣾⣿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠻⡟⠙⡷⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣿⣿⣿⣿⣷⣿⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⡇⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⣻⣟⢿⣿⠟⣋⡀⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠹⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡾⢛⣽⣴⢴⣟⢙⣿⣦⡙⠑⠓⠙⠃⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...