# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1257631 | hickwhither | 은행 (IZhO14_bank) | C++17 | 95 ms | 8644 KiB |
#define mocua(inp, out) if(fopen(inp,"r")){freopen(inp,"r",stdin);freopen(out,"w",stdout);}
#include <iostream>
#include <cstdint>
#include <climits>
#include <cstring>
using namespace std;
const int LOG = (1<<20);
int logN, logM;
int n, m;
int salary[23], note[23];
int covered[LOG];
int miss[LOG];
signed main()
{
cin.tie(0) -> sync_with_stdio(0);
mocua("TABLE.INP", "TABLE.OUT");
cin >> n >> m;
logN = (1<<n);
logM = (1<<m);
for(int i=0; i<n; ++i) cin >> salary[i];
for(int i=0; i<m; ++i) cin >> note[i];
memset(covered, -1, sizeof covered);
memset(miss, -1, sizeof miss);
covered[0] = miss[0] = 0;
for(int mask=1, old; mask<logM; ++mask){
for(int i=0; i<m; ++i)if(mask>>i&1){
old = mask^(1<<i);
if(covered[old]==-1)continue;
int val = miss[old]+note[i];
int tar = salary[covered[old]];
if(val < tar){
covered[mask] = covered[old];
miss[mask] = val;
}
else if(val==tar){
covered[mask] = covered[old]+1;
miss[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... |