Submission #1001754

#TimeUsernameProblemLanguageResultExecution timeMemory
1001754hehebjp123Bank (IZhO14_bank)C++14
0 / 100
15 ms33116 KiB
#include<bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #define ii pair<ll,ll> using namespace std; const ll mod=1e9+7; const ll len=21; ll res=0,mi,gcd=0,d=0,i,n,m,j; ll a[len],b[len]; ii dp[1<<len]; ii cmp(ii a,ii b) { return (a.fi==b.fi?(a.se<b.se? a:b):(a.fi>b.fi?a:b)); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>m; for(i=1;i<=n;i++) cin>>a[i]; for(i=0;i<m;i++) cin>>b[i]; // dp[mask] còn bnh thg cần fill memset(dp,-1,sizeof(dp)); dp[0]={0,a[1]}; //8cout<<cmp(dp[1],dp[0]).fi<<" "; for(ll mask=0;mask<(1<<m);mask++) { for(ll i=0;i<m;i++) if(!(mask&(1<<i))) { // if(mask==0)cout<<mask<<" "<<(mask|(1<<i))<<'\n'; if(b[i]<=dp[i].se) { if(b[i]==dp[i].se) { if(dp[i].fi==n-1) return cout<<"YES",0; dp[mask|(1<<i)]=cmp(dp[mask|(1<<i)],{dp[i].fi+1,a[dp[i].fi+2]}); } else { dp[mask|(1<<i)]=cmp(dp[mask|(1<<i)],{dp[i].fi,dp[mask].se-b[i]}); } } } } //cout<<dp[2].fi<<' '<<dp[2].se<<" "; cout<<"NO"; return 0; } // d=ma-mi mi=2*x-ma

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:28:24: 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]
   28 | 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...