Submission #765654

# Submission time Handle Problem Language Result Execution time Memory
765654 2023-06-25T01:22:05 Z tinhngoVN Bank (IZhO14_bank) C++14
0 / 100
1 ms 2260 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 20 + 5;
const int MAXM = 14 + 5;
const int MAXS = (1 << MAXM) + 5;

int N, M;
int a[MAXN], b[MAXM];
int dp[MAXS];

int main() {
    // Đọc dữ liệu đầu vào
    cin >> N >> M;
    for (int i = 1; i <= N; ++i)
        cin >> a[i];
    for (int i = 0; i < M; ++i)
        cin >> b[i];

    // Khởi tạo giá trị cho dp
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;

    // Duyệt qua các trạng thái của Bitmask
    for (int s = 0; s < (1 << M); ++s) {
        // Nếu trạng thái không khả dụng, bỏ qua
        if (dp[s] == -1)
            continue;

        // Duyệt qua các tờ tiền để chọn
        for (int i = 0; i < M; ++i) {
            // Nếu tờ tiền đã được chọn, bỏ qua
            if (s & (1 << i))
                continue;

            // Cập nhật trạng thái mới
            int t = s | (1 << i);
            int sum = dp[s] + b[i];

            // Duyệt qua các người để trả lương
            for (int j = 1; j <= N; ++j) {
                if (a[j] <= sum) {
                    int diff = sum - a[j];
                    dp[t] = max(dp[t], diff);
                }
            }
        }
    }

    // Kiểm tra kết quả
    if (dp[(1 << M) - 1] == 0)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -