제출 #1344936

#제출 시각아이디문제언어결과실행 시간메모리
1344936msun은행 (IZhO14_bank)C++20
0 / 100
3 ms4420 KiB
#include <cstdio>
#include <cstring>

using namespace std;

#define MX 20

int A[MX], B[MX];
int dp[1 << MX], paid[1 << MX];

int
main ()
{
    // freopen ("test.in", "r", stdin);

    int N, M;
    scanf ("%d%d", &N, &M);

    for (int i = 0; i < N; ++i)
        scanf ("%d", &A[i]);

    for (int i = 0; i < N; ++i)
        scanf ("%d", &B[i]);

    memset (dp, -0x3f, sizeof dp);
    dp[0] = 0;

    int S = 1 << M;
    for (int s = 1; s < S; ++s) {
        for (int x = 0; x < M; ++x)
            if (s & (1 << x)) {
                int ssubx = s ^ (1 << x);

                if (dp[ssubx] < 0)
                    continue;

                dp[s]    = dp[ssubx];
                int amt  = paid[ssubx] + B[dp[ssubx]];
                int targ = A[dp[ssubx]];

                if (amt < targ) {
                    paid[s] = amt;
                } else if (amt == targ) {
                    ++dp[s];
                    paid[s] = 0;
                }
            }

        if (dp[s] == N) {
            puts ("YES");
            return 0;
        }
    }

    puts ("NO");

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:17:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf ("%d%d", &N, &M);
      |     ~~~~~~^~~~~~~~~~~~~~~~
bank.cpp:20:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf ("%d", &A[i]);
      |         ~~~~~~^~~~~~~~~~~~~
bank.cpp:23:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf ("%d", &B[i]);
      |         ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...