Submission #580542

#TimeUsernameProblemLanguageResultExecution timeMemory
580542yutabi은행 (IZhO14_bank)C++14
19 / 100
1 ms212 KiB
#include <bits/stdc++.h>
using namespace std;


#define pb push_back


typedef long long ll;
typedef pair <ll,ll> ii;

int n;
int m;

vector <int> s;
vector <int> x;

bool DP[1001][1001];

int main()
{
    scanf("%d %d",&n,&m);
    
    for(int i=0;i<n;i++)
    {
        int a;

        scanf(" %d",&a);

        s.pb(a);
    }

    for(int i=0;i<m;i++)
    {
        int a;

        scanf(" %d",&a);

        x.pb(a);
    }

    DP[0][0]=1;

    for(int i=0;i<m;i++)
    {
        for(int j=0;j<1001;j++)
        {
            if(x[i]+j<1001 && DP[i][j]==1)
            {
                DP[i+1][x[i]+j]=1;
            }

            if(DP[i][j])
            {
                DP[i+1][j]=1;
            }
        }
    }

    if(DP[m][s[0]])
    {
        printf("YES");
    }

    else
    {
        printf("NO");
    }
}

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
bank.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
bank.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...