Submission #1089196

#TimeUsernameProblemLanguageResultExecution timeMemory
1089196vjudge1Bank (IZhO14_bank)C++17
71 / 100
1097 ms600 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ll int #define F first #define S second #define ull unsigned long long #define db double #define ldb long double #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> #define all(x) x.begin(), x.end() const int mod = 1e9 + 7; const int N = 20001; using namespace std; using namespace __gnu_pbds; ll n, m, k, p[N], f[N], a, b, ans, used[N]; vector <ll> v, q; void rec (ll id, vector <ll> v){ if (id == n + 1){ cout << "YES"; exit (0); } if (v.size() == 0){ return; } a = 0; for (auto i: v){ a += i; } if (a < p[id]){ return; } for (int i = 1; i < (1 << v.size()); i++){ a = 0; for (int y = 0; y < v.size(); y++){ used[y] = 0; if ((i >> y) & 1){ a += v[y]; used[y] = 1; } if (a > p[id]){ break; } } // cout << '\n'; if (a == p[id]){ q.clear(); for (int y = 0; y < v.size(); y++){ if (used[y] == 0){ q.pb (v[y]); } } rec (id + 1, q); } } } signed main (){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++){ cin >> p[i]; } sort (p + 1,p + n + 1); for (int i = 1; i <= m; i++){ cin >> f[i]; v.pb (f[i]); } sort (all(v)); rec (1,v); cout << "NO"; }

Compilation message (stderr)

bank.cpp: In function 'void rec(int, std::vector<int>)':
bank.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int y = 0; y < v.size(); y++){
      |                   ~~^~~~~~~~~~
bank.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |    for (int y = 0; y < v.size(); y++){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...