Submission #1111836

#TimeUsernameProblemLanguageResultExecution timeMemory
1111836themaver1cksBank (IZhO14_bank)C++14
44 / 100
1071 ms504 KiB
/** 。∠(*・ω・)っ ⌒ 由 ~ (( ,,・з・,, )) _Π_____。 /______/~\ | 田田|門| > love miku so muchhhh <3 **/ #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define sz(x) (int)(x).size() #define el "\n" typedef long long ll; typedef pair<int,int> pii; typedef double db; // var dec const int maxn = 22; int n, m; // ds dec int a[maxn], b[maxn]; // namespace sub1 { bool condition() { return (n == 1); } // void solve() { bool ans = 0; for (int mask=1; mask<(1<<m); ++mask) { int sum = 0; for (int j=0; j<m; ++j) if (mask & (1<<j)) sum += b[j+1]; if (sum == a[1]) { ans = 1; break; } } cout << (ans ? "YES" : "NO") << el; } } // namespace sub2 { bool condition() { return (n <= 10 && m <= 10); } // void solve() { vector <vector<bool>> dp(n+3, vector<bool>((1<<m)+3, 0)); dp[0][0] = 1; for (int i=1; i<=n; ++i) { for (int mask=1; mask<(1<<m); ++mask) { for (int pre_mask=0; pre_mask<(1<<m); ++pre_mask) { if (mask & pre_mask) continue; int sum = 0; for (int j=0; j<m; ++j) if (mask & (1<<j)) sum += b[j+1]; int cur_mask = (mask | pre_mask); if (sum == a[i]) dp[i][cur_mask] = (dp[i][cur_mask] | dp[i-1][pre_mask]); } } } for (int mask=1; mask<(1<<m); ++mask) { if (dp[n][mask]) return void(cout << "YES" << el); } cout << "NO" << el; } } // void solve() { cin >> n >> m; for (int i=1; i<=n; ++i) cin >> a[i]; for (int i=1; i<=m; ++i) cin >> b[i]; if (sub1::condition()) sub1::solve(); else sub2::solve(); // else if (sub2::condition()) sub2::solve(); } // int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("lmao.inp", "r")) { freopen("lmao.inp", "r", stdin); freopen("lmao.out", "w", stdout); } int t = 1; // cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int32_t main()':
bank.cpp:101:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |         freopen("lmao.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:102:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |         freopen("lmao.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...