제출 #547948

#제출 시각아이디문제언어결과실행 시간메모리
547948mgl_diamond은행 (IZhO14_bank)C++14
52 / 100
1094 ms14984 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using pd = pair<double, double>; #define fi first #define se second #define debug(x) cout << #x << ": " << x << "\n" #define all(x) x.begin(), x.end() template<class T> bool umax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool umin(T &a, T b) { if (a>b) { a=b; return 1; } return 0; } void setIO(string name="") { ios_base::sync_with_stdio(0); cin.tie(0); if (name.size()) freopen((name+".inp").c_str(),"r",stdin); if (name.size()) freopen((name+".out").c_str(),"w",stdout); } int n, m; vector<int> a, b, prv, cur; vector<vector<int>> dp; int main() { setIO(""); cin >> n >> m; a.resize(n); for(int &x: a) cin >> x; b.resize(m); for(int &x: b) cin >> x; ///* dp.resize(1001, vector<int>()); for(int i=0; i<1<<m; ++i) { int sum=0; for(int j=0; j<m; ++j) if (i>>j&1) sum+=b[j]; if (sum<=1000) dp[sum].push_back(i); } //*/ ///* prv.resize(1<<m); cur.resize(1<<m); prv[0]=1; for(int k=0; k<n; ++k) { for(int i=0; i<1<<m; ++i) for(int j: dp[a[k]]) if ((j&i)==j) cur[i]+=prv[i-j]; for(int i=0; i<1<<m; ++i) { prv[i]=cur[i]; cur[i]=0; } } //*/ for(int i=0; i<1<<m; ++i) if (prv[i]>0) { cout << "YES\n"; return 0; } cout << "NO\n"; }

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

bank.cpp: In function 'void setIO(std::string)':
bank.cpp:17:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  if (name.size()) freopen((name+".inp").c_str(),"r",stdin);
      |                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:18:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  if (name.size()) freopen((name+".out").c_str(),"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...