제출 #68487

#제출 시각아이디문제언어결과실행 시간메모리
68487MrTEK은행 (IZhO14_bank)C++14
100 / 100
431 ms22888 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define len(a) (int)a.size() #define fi first #define sc second #define cout maltahsin #define left ind + ind #define right ind + ind + 1 #define mid (l + r) / 2 #define d1(w) cerr<<#w<<":"<<w<<endl; #define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl; #define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl; #define FAST_IO ios_base::sync_with_stdio(false); #define endl '\n' const int maxn = 620; const long long LINF = 1e18; const int LOG = 31; const int INF = 1e9 + 5; const int N = 20; const int M = (2 << 20) + 5; const int K = 1e3 + 5; const int SQ = 350; const int MOD = 998244353; typedef pair <int,int> pii; vector <int> S[K]; int n,m,dp[2][M],a[N],b[N]; void brute(int cur,int sum,int mask) { if (cur == m) { if (sum <= 1e3) S[sum].push_back(mask); return; } brute(cur + 1,sum,mask); brute(cur + 1,sum + b[cur],mask + (1 << cur)); } int main() { scanf("%d %d",&n,&m); for (int i = 0 ; i < n ; i++) scanf("%d",&a[i]); for (int i = 0 ; i < m ; i++) scanf("%d",&b[i]); brute(0,0,0); dp[0][0] = 1; int cur = 0, nxt = 1; for (int i = 0 ; i < n ; i++) { for (int j = 0 ; j < M ; j++) { if (!dp[cur][j]) continue; for (auto it : S[a[i]]) { if ((j & it) == 0) { dp[nxt][j + it] |= dp[cur][j]; } } } for (int j = 0 ; j < M ; j++) dp[cur][j] = 0; swap(cur,nxt); } int ans = 0; for (int i = 0 ; i < M ; i++) ans |= dp[cur][i]; printf(ans ? "YES\n" : "NO\n"); }

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

bank.cpp: In function 'int main()':
bank.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
bank.cpp:48:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0 ; i < n ; i++) scanf("%d",&a[i]);
                                ~~~~~^~~~~~~~~~~~
bank.cpp:49:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0 ; i < m ; i++) scanf("%d",&b[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...