Submission #1107240

#TimeUsernameProblemLanguageResultExecution timeMemory
1107240vjudge1Bank (IZhO14_bank)C++17
19 / 100
1 ms4600 KiB
#include <bits/stdc++.h> #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ff first #define int long long #define ss second #define pb push_back #define y1 zildjian using namespace std; const int N = 5e5+100; const int INF = 1e18; const int mod = 1e9+7; const int dx[] = {-1,-1,0,1,1,1,0,-1,0}; const int dy[] = {0,1,1,1,0,-1,-1,-1,0}; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int binpow (int a, int n){ if (n == 0) return 1; if (n % 2 == 1) return (binpow (a, n-1)%mod * a%mod)%mod; else { int b = binpow (a, n/2) % mod; return (b%mod * b%mod)%mod; } } int n,m; int a[N],b[N]; int dp[N]; void solve(){ cin>>n>>m; int s = 0; for(int i = 1;i<=n;i++){ cin>>a[i]; s+=a[i]; } for(int i = 1;i<=m;i++){ cin>>b[i]; } dp[0] = 1; for(int i = 1;i<=m;i++){ for(int j = s;j>=b[i];j--){ if(dp[j-b[i]]) dp[j] = 1; } } if(dp[s]) yes; else no; } signed main(){ // freopen("floyd.in","r",stdin); // freopen("floyd.out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(nullptr); // cout.tie(nullptr); int T = 1; // cin>>T; for(int i = 1;i<=T;i++){ // cout<<"Case "<<i<<": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...