제출 #1013246

#제출 시각아이디문제언어결과실행 시간메모리
1013246vjudge1은행 (IZhO14_bank)C++17
100 / 100
753 ms3416 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using pl = pair<ll, ll>; using tl = tuple<ll, ll, ll>; #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz(x) ll(x.size()) #define pb emplace_back #define F first #define S second const ll inf = 1e17; const ll mod = 1e9 + 7; const ll N = 1e5*5+10; const ll K = 300; inline ll add(ll a, ll b){ if(a + b >= mod) return a + b - mod; return a + b; } void solve() { ll n, m; cin >> n >> m; vector<ll> a(n), b(m); for(auto &i : a) cin >> i; for(auto &i : b) cin >> i; vector<vector<bool>> dp(n+1, vector<bool> (1<<m)); ll pr = 0; dp[0][0]=1; bool yes = 0; for(ll i = 0; i < n; i++){ pr += a[i]; for(ll mask = 0; mask < (1<<m); mask++){ if(dp[i][mask] == 0)continue; ll sum = 0; for(ll j = 0; j < m; j++) sum+=((mask>>j)&1)*b[j]; if(sum == pr) dp[i+1][mask] = 1, yes|=(i == n-1); for(ll j = 0; j < m; j++){ if((mask>>j)&1)continue; ll to = (mask|(1<<j)); dp[i][to] = 1; } } } cout << (yes ? "YES" : "NO") ; } int main() { ios::sync_with_stdio(0); cin.tie(0); ll t = 1, i=1; //cin >> t; while (t--) { //cout << "Case " << i++ << ":\n"; solve(); } }

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

bank.cpp: In function 'int main()':
bank.cpp:59:15: warning: unused variable 'i' [-Wunused-variable]
   59 |     ll t = 1, i=1;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...