제출 #661110

#제출 시각아이디문제언어결과실행 시간메모리
661110hafo은행 (IZhO14_bank)C++14
25 / 100
540 ms262144 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define pa pair<int, int> #define pall pair<ll, int> #define fi first #define se second #define TASK "test" #define all(x) x.begin(), x.end() using namespace std; template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;} const int MOD = 1e9 + 7; const int LOG = 20; const int maxn = 20; const ll oo = 1e15 + 69; int n, m, a[maxn], b[maxn], id[maxn]; pa dp[1 << maxn][maxn]; vector<int> cur[maxn]; bool getbit(const int mask, int i) { return ((mask >> i) & 1); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen(TASK".inp", "r", stdin); //freopen(TASK".out", "w", stdout); cin>>n>>m; for(int i = 0; i < n; i++) cin>>a[i]; for(int i = 0; i < m; i++) cin>>b[i]; for(int i = 0; i < n; i++) for(int mask = 0; mask < (1 << m); mask++) dp[mask][i] = make_pair(-1, 0); dp[0][0] = {0, 0}; cur[0].pb(0); int mask; for(int i = 0; i < n; i++) for(id[i]; id[i] < cur[i].size(); id[i]++) { mask = cur[i][id[i]]; for(int j = 0; j < m; j++) if(!getbit(mask, j)) { int s = dp[mask][i].se + b[j], add = (s == a[i]); cur[i + add].pb(mask | (1 << j)); dp[mask | (1 << j)][i + add] = {i + add, (add == 0 ? s:0)}; if(i + add == n) { cout<<"YES"; exit(0); } } } cout<<"NO"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:47:17: warning: statement has no effect [-Wunused-value]
   47 |         for(id[i]; id[i] < cur[i].size(); id[i]++) {
      |             ~~~~^
bank.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(id[i]; id[i] < cur[i].size(); id[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...