제출 #1058083

#제출 시각아이디문제언어결과실행 시간메모리
1058083vjudge1은행 (IZhO14_bank)C++17
19 / 100
108 ms12924 KiB
#include<bits/stdc++.h> #define ll long long #define ii pair < int , int > #define iii pair < int , ii> #define iv pair < ii , ii > #define fi first #define se second using namespace std; const int N = 23; const int mod = 1e9 + 7; const int tt = 1e6; const int base = 311; int n, m; int a[N], b[N], s[1 << N], presum[N], d[1 << N]; bool dp[1 << N]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i], presum[i] = presum[i - 1] + a[i]; for(int j = 0; j < m; j++) cin >> b[j]; for(int mask = 0; mask < (1 << m); mask++) { int sum = 0; for(int j = 0; j < m; j++) if((mask >> j) & 1) sum += b[j]; s[mask] = sum; } int cur = 0; dp[0] = 1; d[0] = 0; for(int mask = 1; mask < (1 << m); mask++){ int check = 0; for(int j = 0; j < m; j++) if((mask >> j) & 1 && dp[mask ^ (1 << j)] == 1 && d[mask ^ (1 << j)] == cur) check = 1; if(check){ dp[mask] = 1; if(s[mask] == presum[cur + 1]) cur++; d[mask] = cur; // cout << s[mask] << " " << presum[cur + 1] << endl; } // cout << mask << " " << dp[mask] << " " << d[mask] << endl; } // cout << cur << endl; if(cur == n) cout << "YES"; else cout << "NO"; }

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

bank.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...