Submission #1128152

#TimeUsernameProblemLanguageResultExecution timeMemory
1128152alimkhanBank (IZhO14_bank)C++20
44 / 100
1094 ms328 KiB
//Bismillahir-Rahmanir-Rahim #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ld long double #define dbg(x) cerr << #x << " = " << x << "\n"; #define ff first #define ss second /* #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma comment (linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */ const long long INF = 1e9 + 7; const long long MOD = 1e9 + 7; const int maxn = 1e5 + 20; // const int lg = 20; int n, m, a[maxn], b[maxn]; namespace n1{ int dp[maxn]; void solve() { dp[0] = 1; for (int j = 1; j <= m; j++) { for (int i = 1000; i >= 0; i--) { if (dp[i] == 1) { dp[i + b[j]] = 1; } } } if (dp[a[1]] == 1) { cout << "YES"; } else { cout << "NO"; } } } namespace n10m10{ void solve() { sort(b + 1, b + m + 1); sort(a + 1, a + n + 1); do { int id = 1; int sum = 0; for (int j = 1; j <= m; j++) { sum += b[j]; if (id > n) { break; } if (sum == a[id]) { sum -= a[id]; id++; } if (sum > a[id]) { break; } } if (id > n) { cout << "YES"; return; } } while(next_permutation(b + 1, b + m + 1)); cout << "NO"; } } void press_F_() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int j = 1; j <= m; j++) { cin >> b[j]; } if (n == 1) { n1::solve(); return; } // if (n <= 10 && m <= 10) { n10m10::solve(); // return; // } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; // cin >> T; for (int _ = 1; _ <= T; ++_) { // cout << "Case " << i << ": "; press_F_(); } //Respa gold 2025 InshAllah // return 0; } /* Maybe not today and tomorrow, but InshAllah one day I will reach cm */ // g++ -std=c++17 main.cpp // ./a.out
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...