제출 #1000400

#제출 시각아이디문제언어결과실행 시간메모리
1000400akkshaysr은행 (IZhO14_bank)C++17
100 / 100
128 ms16896 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define fr first #define se second #define rep(i,a,b) for(int i = a; i < (b); ++i) #define rrep(i,a,b) for(int i = a; i > (b); --i) #define sz(x) (int)(x).size() #define all(x) (x).begin(),(x).end() #define IN(i,l,r) (l<i&&i<r) #define pb push_back #define ones __builtin_popcountll using namespace std; using namespace __gnu_pbds; template <class T> using OSTree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<long long> vll; typedef long long ll; const int U = 20; int main(){ cin.tie(0)->sync_with_stdio(false); int n,m; cin >> n >> m; vi a(n), b(m); rep(i,0,n) cin >> a[i]; rep(i,0,m) cin >> b[i]; vll dp(1<<U,-1), remcash(1<<U,-1); dp[0] = 0; remcash[0] = 0; bool flag = false; rep(i,1,1<<m){ rep(j,0,m){ if(i&(1<<j) == 0) continue; int z = i ^ (1<<j); if(dp[z] < 0) continue; if(remcash[z] + b[j] < a[dp[z]]){ dp[i] = dp[z]; remcash[i] = remcash[z] + b[j]; }else if(remcash[z] + b[j] == a[dp[z]]){ dp[i] = dp[z] + 1; remcash[i] = 0; } } if(dp[i] == n){ flag = true; break; } } cout << (flag ? "YES" : "NO") << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:34:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   34 |             if(i&(1<<j) == 0) continue;
      |                  ~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...