답안 #710800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710800 2023-03-15T20:35:29 Z MinaRagy06 은행 (IZhO14_bank) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define lesgooo ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl    '\n'
#define int     long long

int a[25], b[25];
bool dp[21][1 << 20];
int n, m;

bool solve(int lvl, int msk, int rem, int i)
{
    if (i == m)
    {
        if (rem == 0) return dp[lvl+1][msk];
        return 0;
    }
    return ((msk | (1 << i)) != msk && rem-b[i] >= 0? solve(lvl, msk | (1 << i), rem-b[i], i+1): 0) || solve(lvl, msk, rem, i+1);
}
signed main()
{
    lesgooo;
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < (1 << m); i++) dp[n][i] = 1;
    for (int i = n-1; i >= 0; i--) for (int j = 0; j < (1 << 0); j++)
    {
        dp[i][j] = solve(i, j, a[i], 0);
    }
    cout << (dp[0][0]? "Yes" : "No");
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -