結果
問題 |
No.1701 half price
|
ユーザー |
|
提出日時 | 2022-08-22 06:19:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 942 bytes |
コンパイル時間 | 2,098 ms |
コンパイル使用メモリ | 195,596 KB |
最終ジャッジ日時 | 2025-01-31 02:43:28 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 WA * 4 |
ソースコード
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ll n,w; std::cin >> n>>w; vector<ll> a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; } ll ans = 0; for (int i = 0; i < (1<<n); i++) { ll sum = 0; vector<ll> kon; for (int j = 0; j < n; j++) { if(i>>j&1){ sum += a[j]; kon.push_back(a[j]); } } if(sum==w){ ans++; continue; }else{ bool ok = false; for (int j = 0; j < (1<<kon.size()); j++) { ll sum2 = 0; for (int k = 0; k < kon.size(); k++) { if(j>>k&1)sum2+=kon[k]/2; } if(sum-sum2==w)ok=true; } if(ok)ans++; } } std::cout << ans << std::endl; }