제출 #285313

#제출 시각아이디문제언어결과실행 시간메모리
285313BeanZBank (IZhO14_bank)C++11
100 / 100
141 ms8732 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll int
#define endl '\n'

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
vector<ll> choice[1005];
ll a[25], b[25];
pair<ll, ll> dp[1500000];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("VietCT.INP", "r")){
                freopen("VietCT.INP", "r", stdin);
                freopen("VietCT.OUT", "w", stdout);
        }
        ll n, m;
        cin >> n >> m;
        for (int i = 0; i < n; i++) cin >> a[i];
        for (int i = 0; i < m; i++) cin >> b[i];
        bool flag = false;
        for (int i = 1; i < (1 << m); i++){
                for (int j = 0; j < m; j++){
                        if (i & (1 << j)){
                                pair<ll, ll> x = dp[i ^ (1 << j)];
                                x.second = x.second + b[j];
                                if (x.second == a[x.first]){
                                        x.first++;
                                        x.second = 0;
                                }
                                dp[i] = max(dp[i], x);
                                if (x.first == n) flag = true;
                        }
                }
        }
        if (flag) cout << "YES";
        else cout << "NO";
}
/*
*/

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

bank.cpp: In function 'int main()':
bank.cpp:17:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |                 freopen("VietCT.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:18:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   18 |                 freopen("VietCT.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...