Submission #922417

#TimeUsernameProblemLanguageResultExecution timeMemory
922417NurislamBank (IZhO14_bank)C++17
44 / 100
312 ms26636 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int long long #define double long double #define order_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ///* __ __ __ */ ///* ====== _ /| /| __ _ / | | /| | @ | | | | / /| |\ | / | | @ | / */ ///* \- || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */ ///* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */ ///* typedef vector<int> vi; typedef vector<double> vd; typedef pair<int,int> pii; typedef vector<pii> vii; typedef vector<vi> vv; const int N = 2e5+4, inf = 1e8, mod = 998244353; void solve(){ int n, m; cin >> n >> m; int cnt = 0, us[m]{}; vi b(m); map<int,int> mp; for(int i = 0, x; i < n; i++){cin >> x;mp[x]++;} for(int &i:b)cin >> i; vector<pair<pii, int> > res; for(int ms = 1; ms < (1<<m); ms++){ int sum = 0;for(int i = 0; i < m; i++)if((ms>>i)&1)sum+=b[i]; res.pb({{sum , __builtin_popcount(ms)}, ms}); } sort(all(res)); for(auto [uk, ms]:res){ int ok = 0, sum = uk.ff; for(int i = 0; i < m; i++){ if((ms>>i)&1 && us[i])ok = 1; } //~ cout << sum << '\n'; if(ok)continue; if(mp[sum] > 0){ mp[sum]--; cnt++; for(int i = 0; i < m; i++){ if((ms >> i)&1)us[i] = 1; } } } if(cnt == n)cout << "YES\n"; else cout << "NO\n"; } main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int test = 1; //~ cin >> test; while(test--){ solve(); } }

Compilation message (stderr)

bank.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   65 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...