# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1001792 | vjudge1 | 은행 (IZhO14_bank) | C++14 | 66 ms | 8612 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define taskname ""
using namespace std;
ll m, n, i, q, t, j, w, a[29], b[29];
pii dp[1048580], k;
int main() {
if (fopen(taskname".inp","r")) {
freopen(taskname".inp","r",stdin);
freopen(taskname".out","w",stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(i = 1; i <= n; i++) cin >> a[i];
for(i = 1; i <= m; i++) cin >> b[i];
t = 1 << m;
dp[0] = {0, a[1]};
for(i = 1; i < t; i++){
q = 1;
for(j = 1; j <= m; j++){
w = q & i;
if(w){
if(b[j] <= dp[i - q].se){
dp[i] = {dp[i - q].fi, dp[i - q].se - b[j]};
if(dp[i].se == 0){
dp[i].fi++;
if(dp[i].fi == n){
cout << "YES";
return 0;
}
dp[i].se = a[dp[i].fi + 1];
}
}
}
q <<= 1;
}
}
cout << "NO";
//cout << dp[16].fi;
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... |