Submission #1088564

#TimeUsernameProblemLanguageResultExecution timeMemory
1088564vjudge1Bank (IZhO14_bank)C++17
46 / 100
1 ms604 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[1001][101]; bool used[101]; vi notas; bool subsetSum(int sum, int idx, int m) { if (sum == 0) return true; if (idx >= m || sum < 0) return false; if (dp[sum][idx] != -1) return dp[sum][idx]; bool pegar = false; if (!used[idx] && sum >= notas[idx]) { used[idx] = true; pegar = subsetSum(sum - notas[idx], 0, m); used[idx] = false; } bool n_pegar = subsetSum(sum, idx + 1, m); return dp[sum][idx] = pegar || n_pegar; } int main() { int n, m; cin >> n >> m; vector<int> salarios(n); notas.resize(m); for (int i = 0; i < n; i++) { cin >> salarios[i]; } for (int i = 0; i < m; i++) { cin >> notas[i]; } for (int i = 0; i < n; i++) { memset(dp, -1, sizeof(dp)); memset(used, false, sizeof(used)); if (!subsetSum(salarios[i], 0, m)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }

Compilation message (stderr)

bank.cpp: In function 'bool subsetSum(int, int, int)':
bank.cpp:43:25: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   43 |     return dp[sum][idx] = pegar || n_pegar;
      |            ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...