# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1183116 | pete555 | 은행 (IZhO14_bank) | C++17 | 99 ms | 8640 KiB |
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ll long long
#define pb push_back
#define pf push_front
void fileIO(string filename) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
const int MOD = 1e9+7;
int main()
{
cin.tie(0)->sync_with_stdio(false);
//fileIO("");
int n, m;
cin >> n >> m;
int a[n], b[m];
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < m; i++) cin >> b[i];
int covered[1<<m], left[1<<m];
memset(covered, -1, sizeof(covered));
memset(left, -1, sizeof(left));
covered[0] = left[0] = 0;
for(int mask = 0; mask < (1<<m); mask++){
for(int i = 0; i < m; i++){
if(mask & (1<<i)){
int prev = (mask ^ (1<<i));
if(covered[prev] == -1) continue;
int sal = a[covered[prev]];
int amt = b[i] + left[prev];
if(amt < sal){
covered[mask] = covered[prev];
left[mask] = amt;
}
else if(amt == sal){
covered[mask] = covered[prev] + 1;
left[mask] = 0;
}
}
}
if(covered[mask] == n){
cout << "YES";
return 0;
}
}
cout << "NO";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |