Submission #16938

#TimeUsernameProblemLanguageResultExecution timeMemory
16938muratBank (IZhO14_bank)C++98
100 / 100
129 ms4852 KiB
#include <bits/stdc++.h> using namespace std; #define dbgs(x) cerr << (#x) << " --> " << (x) << ' ' #define dbg(x) cerr << (#x) << " --> " << (x) << endl #define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++) #define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++) #define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--) #define type(x) __typeof(x.begin()) #define orta (bas + son >> 1) #define sag (k + k + 1) #define sol (k + k) #define pb push_back #define mp make_pair #define nd second #define st first #define endl '\n' typedef pair < int ,int > pii; typedef long long ll; const long long linf = 1e18+5; const int mod = (int) 1e9 + 7; const int logN = 17; const int inf = 1e9; const int N = 2e5 + 5; int n, m, a[N], b[N], dp[1 << 20]; int f(int w, int mask, int res) { if(w == m+1) return 1; int &r = dp[mask]; if(r != -1) return r; r = 0; FOR(i, 1, n) if(!((1 << i-1) & mask) && res - a[i] >= 0) { if(res == a[i]) r = max(r, f(w+1, mask | (1 << i-1), b[w+1])); else r = max(r, f(w, mask | (1 << i-1), res-a[i])); } return r; } int main() { scanf("%d %d", &m, &n); FOR(i, 1, m) scanf("%d", &b[i]); FOR(i, 1, n) scanf("%d", &a[i]); memset(dp, -1, sizeof dp); if(f(1, 0, b[1])) cout << "YES\n"; else cout << "NO\n"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int f(int, int, int)':
bank.cpp:44:21: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
         if(!((1 << i-1) & mask) && res - a[i] >= 0) {
                    ~^~
bank.cpp:46:49: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
                 r = max(r, f(w+1, mask | (1 << i-1), b[w+1]));
                                                ~^~
bank.cpp:48:47: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
                 r = max(r, f(w, mask | (1 << i-1), res-a[i]));
                                              ~^~
bank.cpp: In function 'int main()':
bank.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &m, &n);
     ~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &b[i]);
         ~~~~~^~~~~~~~~~~~~
bank.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...