Submission #1183439

#TimeUsernameProblemLanguageResultExecution timeMemory
1183439al_reem_2010Bank (IZhO14_bank)C++20
19 / 100
1 ms328 KiB
// اَللَهُمَ صَلِ عَلَىَ مُحَمَدٍ وَ آلِ مُحَمَدٍ
#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <thread>
#include <fstream>
using namespace std ;
#define int long long
#define pb push_back
#define si size()
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define applejuice ios::sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ;
const int inf=1e18 ;
const int mod=1e9+7 ;
int tt=1 ;
int a[27] , b[27] ;
bool dp[1007][1007] ; 
void solve()
{
    // n=1
    int n , m ;
    cin >> n >> m ;
    for(int i=0 ; i<n ; i++) {cin >> a[i] ;}
    for(int i=0 ; i<m ; i++) {cin >> b[i] ;}
    dp[0][0]=1 ;
    for(int i=0 ; i<m ; i++)
    {
        for(int j=0 ; j<=a[0] ; j++)
        {
            dp[i+1][j]=dp[i][j] ;
            if(j>=b[i]) {dp[i+1][j]=dp[i+1][j] || dp[i][j-b[i]] ;}
        }
    }
    cout << (dp[m][a[0]] ? "YES" : "NO") ;
}
signed main()
{
    //wrong
    applejuice ;
    //cin >> tt ;
    while(tt--) {solve() ;}
}
/*
 1 5
 8
 4 2 5 1 3
 
 1 4
 10
 3 1 5 9
 
 1 2
 5
 2 4
 
 1 2
 6
 2 4
 
 */

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...