제출 #1098601

#제출 시각아이디문제언어결과실행 시간메모리
1098601flyingkite은행 (IZhO14_bank)C++17
100 / 100
584 ms12744 KiB
#include <bits/stdc++.h> using namespace std; #define ll int #define pll pair<long long, long long> #define pb push_back #define F first #define S second #define all(x) (x).begin(), (x).end() const ll N = 1002; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll block = 450; const ll base = 31357; ll n,m; ll a[22], b[22], dp[(1 << 20) + 100], lst[(1 << 20) + 100], s[(1 << 20) + 20], ps[22]; void to_thic_cau(){ cin >> n >> m; for(int i = 0; i < n;i++){ cin >> a[i]; ps[i] = (i == 0 ? a[i] : ps[i-1] + a[i]); } for(int i = 0; i < m;i++) cin >> b[i]; for(int msk = 0; msk < (1 << m); msk++){ for(int i = 0; i < m;i++) if(msk & (1 << i)) s[msk] += b[i]; } lst[0] = 1; for(int i = 0; i < n;i++){ for(int msk = 1; msk < (1 << m);msk++){ if(s[msk] != ps[i]) continue; for(int sub = msk; ; sub = (sub - 1) & msk){ if(s[sub ^ msk] == a[i] && s[sub] == (i == 0 ? 0 : ps[i-1]) && lst[sub] == 1){ dp[msk] = 1; break; } if(sub == 0) break; } } for(int msk = 0; msk < (1 << m);msk++) lst[msk] = dp[msk], dp[msk] = 0; } for(int i = 0; i < (1 << m);i++){ if(lst[i]){ cout << "YES" << '\n'; return; } } cout << "NO" << "\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); ll tc = 1; //cin >> tc; while(tc--) to_thic_cau(); }

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

bank.cpp:12:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   12 | const ll inf = 1e18;
      |                ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...