제출 #436594

#제출 시각아이디문제언어결과실행 시간메모리
436594Trinadh724은행 (IZhO14_bank)C++17
100 / 100
143 ms16720 KiB
#include<iostream> #include<vector> #include<algorithm> #include<deque> #include<queue> #include<set> #include<map> #include<string> #include<math.h> using namespace std; #define ll long long #define pb push_back #define ld long double #define ff first #define ss second #define mod 1000000007 ll cd(ll a,ll b) { if(a==0)return b; else if (b==0)return a; else return cd(b,a%b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("bank.in", "r", stdin); // freopen("bank.out", "w", stdout); ll n, m; cin>>n>>m; ll a[n+5], b[m+5]; for(int i=0;i<n;i++){ cin>>a[i]; } for(int j=0;j<m;j++){ cin>>b[j]; } pair<ll,ll> notes[1<<m]; for(int i=0;i<(1<<n); i++){ notes[i] = {0,0}; } ll ans = -1, curr, mon; for(int i=0;i<(1<<m); i++){ for(int s=0;s<m;s++){ if(i & (1<<s)){ curr = notes[i ^ (1<<s)].ff; mon = notes[i ^ (1<<s)].ss; if(mon + b[s] == a[curr]){ curr++; mon = 0; notes[i] = max(notes[i], {curr, mon}); } else{ mon += b[s]; notes[i] = max(notes[i], {curr, mon}); } } } // cout<<i<<" "<<notes[i].ff<<" "<<notes[i].ss<<endl; if(notes[i].ff >= n){ cout<<"YES"<<endl; return 0; } } cout<<"NO"<<endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:49:5: warning: unused variable 'ans' [-Wunused-variable]
   49 |  ll ans = -1, curr, mon;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...