Submission #988272

#TimeUsernameProblemLanguageResultExecution timeMemory
988272TsaganaBank (IZhO14_bank)C++14
52 / 100
17 ms6912 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define int long long #define F first #define S second using namespace std; pair<int, int> dp[200000]; void solve () { vector<int> a, b; int n, m; cin >> n >> m; a.resize(n); b.resize(m); for (int &i: a) cin >> i; for (int &i: b) cin >> i; memset(dp, -1, sizeof dp); dp[0] = {0, 0}; for (int mask = 0; mask < (1 << m); mask++) { for (int last = 0; last < m; last++) { if (!(mask & (1 << last))) continue ; int pre = mask ^ (1 << last); if (dp[pre].F == -1) continue ; int remain = dp[pre].S + b[last]; int need = a[dp[pre].F]; if (remain < need) dp[mask] = {dp[pre].F, remain}; if (remain == need) dp[mask] = {dp[pre].F + 1, 0}; } if (dp[mask].F == n) {cout << "YES"; return ;} } cout << "NO"; } signed main() {IOS solve(); return 0;}

Compilation message (stderr)

bank.cpp: In function 'void solve()':
bank.cpp:18:26: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'struct std::pair<long long int, long long int>' with no trivial copy-assignment [-Wclass-memaccess]
   18 |  memset(dp, -1, sizeof dp);
      |                          ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bank.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'struct std::pair<long long int, long long int>' declared here
  211 |     struct pair
      |            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...