Submission #344532

#TimeUsernameProblemLanguageResultExecution timeMemory
344532mansurBank (IZhO14_bank)C++14
0 / 100
1 ms364 KiB
#include<bits/stdc++.h> using namespace std; #define all(a) a.begin(),a.end() #define ll long long #define pb push_back #define nl '\n' #define popb pop_back() #define sz size() #define ld long double #define ull unsigned long long #define F first #define S second #define fix fixed<<setprecision #define pii pair<int,int> #define E exit (0) #define int1 long long const int inf=1e9; int main() { //freopen("planting.in","r",stdin); //freopen("planting.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; int a[n+1],b[m+1]; for (int i=1;i<=n;i++) { cin>>a[i]; } for (int i=1;i<=m;i++) { cin>>b[i]; } vector<bool>dp(1001); dp[0]=1; for (int i=0;i<=1000;i++) { if (dp[i]) { for (int j=1;j<=m&&i+b[j]<=1000;j++) { dp[i+b[j]]=true; } } } for (int i=1;i<=n;i++) { if (!dp[i]) { cout<<"NO"; E; } } cout<<"YES"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...