| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 734711 | teesla | 은행 (IZhO14_bank) | C++14 | 111 ms | 16752 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n >> m;
vector<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 aa = 1LL << m;
vector<int> dp(aa,0), resto(aa,0);
for(int i=1; i<aa; i++){
for(int j=0; j<m; j++){
int bit = 1LL << j;
if((i&bit) == 0) continue;
if(dp[i-bit] == n) dp[i] = n;
else{
int aux = dp[i-bit], rest = resto[i-bit];
if(rest + b[j] == a[aux]){
aux++;
rest = 0;
}
else rest += b[j];
if(aux >= dp[i]){
dp[i] = aux;
resto[i] = max(rest, resto[i]);
}
}
}
}
if(dp[aa-1] == n) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}| # | 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... | ||||
