제출 #731721

#제출 시각아이디문제언어결과실행 시간메모리
731721Juan은행 (IZhO14_bank)C++17
25 / 100
1082 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define ff first #define ss second const int maxn = 22; int sal[maxn], notes[maxn]; bool dp[maxn][1<<(maxn-1)]; int32_t main(){ int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) cin >> sal[i]; for(int i = 0; i < m; i++) cin >> notes[i]; dp[0][0] = true; for(int i = 1; i <= n; i++){ // p cada mask de notas for(int mask = 0; mask < (1<<m); mask++){ vector<int> aux; for(int e = 0; e < m; e++) if(mask & (1<<e)) aux.push_back(e); // checar, entre as submasks, quais formam salario valido // p sal[i] e se a submask restante eh valida p anterior for(int submask = 0; submask < (1<<aux.size()); submask++){ int submask_val=0, val=0; for(int e = 0; e < aux.size(); e++) if(submask & (1<<e)) val+=notes[aux[e]], submask_val += (1<<(aux[e])); if(val==sal[i] && dp[i-1][mask^submask_val]) dp[i][mask] = true; } } } bool found = false; for(int i = 0; i < (1<<m); i++) if(dp[n][i]) {cout << "YES\n"; found = true; break;} if(found==false) cout << "NO\n"; }

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

bank.cpp: In function 'int32_t main()':
bank.cpp:30:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int e = 0; e < aux.size(); e++) if(submask & (1<<e)) val+=notes[aux[e]], submask_val += (1<<(aux[e]));
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...