제출 #883236

#제출 시각아이디문제언어결과실행 시간메모리
883236cemil1234은행 (IZhO14_bank)C++17
100 / 100
109 ms16876 KiB
#include<bits/stdc++.h> using namespace std; #define ull unsigned long long void solve(){ long long n,m,x; cin>>n>>m; vector<long long>pp(n),bn(m); for(long long i = 0;i<n;i++){ cin>>pp[i]; } for(long long i = 0;i<m;i++){ cin>>bn[i]; } vector<long long>cnt(1<<m,-1),left(1<<m,-1); cnt[0] = 0; left[0] = 0; for(long long i = 0;i<(1<<m);i++){ for(long long j = 0;j<m;j++){ if((i&(1<<j)) == 0){ continue; } long long pre = i^(1<<j); if(cnt[pre] == -1){ continue; } long long nleft = left[pre]+bn[j]; if(nleft == pp[cnt[pre]]){ left[i] = 0; cnt[i] = cnt[pre]+1; } else if(nleft<pp[cnt[pre]]){ left[i] = nleft; cnt[i] = cnt[pre]; } } if(cnt[i] == n){ cout<<"YES\n"; return; } } cout<<"NO\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin>>t; while(t--){ solve(); } }

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

bank.cpp: In function 'void solve()':
bank.cpp:5:19: warning: unused variable 'x' [-Wunused-variable]
    5 |     long long n,m,x;
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...