Submission #743406

#TimeUsernameProblemLanguageResultExecution timeMemory
743406Omar_AlarabyBank (IZhO14_bank)C++17
0 / 100
40 ms16776 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; void Omar_Alaraby(){ ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout); #endif } #define cin2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++); #define cout2d(vec , n , m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] << " "; j++); #define cout_map(mp) for(auto& [first, second] : mp) cout << first << " --> " << second << "\n"; #define put(s) return void(cout << s << dl); #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n"; #define fixed(n) fixed << setprecision(n) #define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0)) #define Num_of_Digits(n) ((int)log10(n) + 1) #define all(vec) vec.begin(), vec.end() #define rall(vec) vec.rbegin(), vec.rend() #define sz(x) int(x.size()) #define ll long long #define ull unsigned long long #define dl "\n" #define ordered_set tree<ll , null_type , less<> , rb_tree_tag , tree_order_statistics_node_update> const ll Mod = 1e9 + 7; template < typename T = int > istream& operator >> (istream &in, vector < T > &v) { for (auto &x : v) in >> x; return in; } template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) { for (const T &x: v) out << x << ' '; return out; } void Solve(){ // cin >> n >> w; // v.resize(n); cin >> v; // vector < pair < int , int > > dp(1 << n, {2e9, 0}); // dp[0] = {0, 0}; // for(int mask = 1; mask < 1 << n; mask++){ // for(int person = 0; person < n; person++){ // if(!(mask & (1 << person))) continue; // pair < int , int > check = dp[mask ^ (1 << person)]; // if(check.second + v[person] <= w) // check.second += v[person]; // else // check.first++, check.second = v[person]; // dp[mask] = min(dp[mask], check); // } // } // cout << dp[(1 << n) - 1].first + (dp[1 << n - 1].second > 0) << dl; int n,m; cin >> n >> m; vector < int > salaries(n); cin >> salaries; vector < int > bankNotes(m); cin >> bankNotes; vector < pair < int , int > > dp(1 << m, {0 , 0}); for(int mask = 1; mask < (1 << m); mask++){ for(int note = 0; note < m; note++){ if(!(mask & (1 << note))) continue; pair < int , int > check = dp[mask ^ (1 << note)]; if(check.second + bankNotes[note] == salaries[check.first]) check.first++, check.second = 0; else if(check.second + bankNotes[note] < salaries[check.first]) check.second += bankNotes[note]; dp[mask] = max(dp[mask], check); } } cout << ((dp[(1 << m) - 1].first == n)? "YES" : "NO") << dl; } int main(){ //Omar_Alaraby(); freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int tc = 1; //cin >> tc; for(int i=1; i<=tc; i++){ //cout << "Scenario #" << i << ":" << dl; Solve(); } Time return 0; }

Compilation message (stderr)

bank.cpp: In function 'void Omar_Alaraby()':
bank.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:12:46: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
      |                                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:95:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |     freopen("bank.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:96:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |     freopen("bank.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...