Submission #1308616

#TimeUsernameProblemLanguageResultExecution timeMemory
1308616AgentPengin은행 (IZhO14_bank)C++20
0 / 100
2 ms832 KiB
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define pii pair<int,int> #define piii pair<int,pair<int,int>> #define vt vector #define unmap unordered_map #define unset unordered_set #define pri priority_queue #define ub upper_bound #define lb lower_bound #define ll long long // #define int long long #define getbit(x,i) ((x >> i) & 1ll) #define NAME "chick" using namespace std; const ll inf = 1e18; const int mod = 1e9 + 7; const int maxn = 21; int n,m,a[maxn],b[maxn],dp[maxn][1<<maxn]; vt<int> d[maxn]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(NAME".inp","r")){ freopen(NAME".inp","r",stdin); freopen(NAME".out","w",stdout); } cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= m; i++){ cin >> b[i]; } sort(a + 1, a + n + 1); sort(b + 1, b + m + 1);// for(int mask = 0; mask < (1 << m); mask++){ int sum = 0; for(int j = 1; j <= m; j++){ if(getbit(mask,j-1)) sum += b[j]; } for(int i = 1; i <= n; i++){ if(a[i] == sum) d[i].pb(mask); } } dp[0][0] = 1; for(int i = 1; i <= n; i++){ for(int mask = 0; mask < (1 << m); mask++){ for(auto x : d[i]){ if(mask & x != x) continue; dp[i][mask] |= dp[i-1][~(mask ^ x)]; } if(i == n && dp[i][mask]){ cout << "YES"; return 0; } } } cout << "NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:32:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |                 freopen(NAME".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:33:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |                 freopen(NAME".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...