Submission #1088484

#TimeUsernameProblemLanguageResultExecution timeMemory
1088484vjudge1Bank (IZhO14_bank)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define _io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pb push_back #define mp make_pair #define f first #define s second #define vi vector<int> #define vll vector<ll> #define MAX 1e9 int dp[30][30]; vi salarios(100); //sums vi notas(100); //set int solve(int n,int sum){ if(sum==0) return 1; if(n<=0) return 0; if(dp[n-1][sum]!=-1) return dp[n-1][sum]; if(notas[n-1] > sum){ return dp[n-1][sum] = solve(n-1,sum); } else{ return dp[n - 1][sum] = solve(n - 1, sum) || solve(n - 1, sum - notas[n - 1]); } } int main(){ _io int n,m; cin >> n >> m; for(int i=0;i<n;i++) cin >> salarios[i]; // vet de sums for(int i=0;i<m;i++) cin >> notas[i]; // bool ok = true; for(int i=0;i<n;i++){ //cout << "vai\n"; memset(dp,-1,sizeof(dp)); if(!solve(m,salarios[i])){ ok=false; break; } } cout << (ok?"YES\n":"NO\n"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...