제출 #973494

#제출 시각아이디문제언어결과실행 시간메모리
973494amirujuz은행 (IZhO14_bank)C++14
19 / 100
83 ms16896 KiB
#include <bits/stdc++.h> #define allr v.rbegin(), v.rend() #define sllr s.rbegin(), s.rend() #define all v.begin(), v.end() #define sll s.begin(), s.end() #define pii pair <int, int> #define int long long #define pb push_back #define pp pop_back #define sc second #define fr first using namespace std; const int N=2097152; signed main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); int mask, sum, n, m, i; cin >> n >> m; vector <int> v(n), k(m), p[n], dp(N); for (i=0; i<n; i++) { cin >> v[i]; } for (i=0; i<m; i++) { cin >> k[i]; } for (mask=0; mask<1<<m; mask++) { sum=0; for (i=0; i<m; i++) { if (mask&(1<<i)) sum+=k[i]; } for (i=0; i<n; i++) { if (sum==v[i]) p[i].pb(mask); } } for (i=1; i<=N; i++) { dp[i]=-1; } for (i=0; i<n; i++) { for (mask=1<<m-1; mask>=0; mask--) { if (dp[mask]!=-1) { for (auto j: p[i]) { if (!(j&mask)) { dp[j|mask]=dp[mask]+1; if (dp[j|mask]==n) { cout << "YES"; return 0; } } } } } } cout << "NO"; }

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

bank.cpp: In function 'int main()':
bank.cpp:40:17: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   40 |   for (mask=1<<m-1; mask>=0; mask--) {
      |                ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...