| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1083504 | sh1ro | Bank (IZhO14_bank) | C++14 | 102 ms | 17660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define fi first
#define se second
using namespace std;
const int N = 1.1e6 + 4;
const int oo = 1e18;
const int mod = 1e9 + 7;
int t, n, q, m, k = 0, ans = -1, a[25], b[25], dp[N]{}, le[N]{};
vector<pair<int, int>>v[1];
void solve(){
cin >> n >> m;
for (int i = 0; i < n; i++)cin >> a[i];
for (int i = 0; i < m; i++)cin >> b[i];
memset(dp, -1, sizeof(dp));
dp[0] = 0;
for (int i = 0; i < (1 << m); i++){
for (int j = 0; j < m; j++){
if ((1 << j) & i == 0 || dp[i ^ (1 << j)] == -1)continue;
if (a[dp[i ^ (1 << j)]] > le[i ^ (1 << j)] + b[j]){
dp[i] = dp[i ^ (1 << j)];
le[i] = le[i ^ (1 << j)] + b[j];
}
else if (a[dp[i ^ (1 << j)]] == le[i ^ (1 << j)] + b[j]){
dp[i] = dp[i ^ (1 << j)] + 1;
le[i] = 0;
}
}
if (dp[i] == n){
cout << "YES";
return;
}
}
cout << "NO";
}
main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
//freopen("guard.in", "r", stdin); freopen("guard.out", "w", stdout);
t = 1;
//cin >> t;
while (t--)solve();
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... | ||||
