| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 495827 | ryangohca | 은행 (IZhO14_bank) | C++17 | 571 ms | 164768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
#define int long long
// Do you remember, the fireworks back then? ~ YooA, Remember Me
using namespace std;
int dp[20][1<<20];
int arr[20], val[20];
unordered_map<int, vector<int>> mp;
int n, m;
bool f(int x, int bm){
if (x == n) return true;
if (dp[x][bm] != -1) return dp[x][bm];
bool ans = false;
for (auto i : mp[arr[x]]){
if ((i & bm) == 0) ans |= f(x+1, bm | i);
}
return dp[x][bm] = ans;
}
main(){
ios_base::sync_with_stdio(0); cin.tie(0);
memset(dp, -1, sizeof dp);
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> arr[i];
mp[arr[i]];
}
for (int i = 0; i < m; i++) cin >> val[i];
for (int i = 1; i < (1<<m); i++){
int s = 0;
for (int j = 0; j < m; j++){
if (i & (1 << j)) s += val[j];
}
if (mp.find(s) != mp.end()) mp[s].push_back(i);
}
bool ans = f(0, 0);
cout << (ans ? "YES" : "NO") << '\n';
}컴파일 시 표준 에러 (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... | ||||
