結果
問題 |
No.1701 half price
|
ユーザー |
|
提出日時 | 2025-09-15 07:31:09 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 96 ms / 3,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 3,222 ms |
コンパイル使用メモリ | 278,812 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-15 07:31:14 |
合計ジャッジ時間 | 4,197 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, w; cin >> n >> w; vector<int> a(n); for(auto&e:a) cin >> e; long ans = 0; for(int i = 1; i < 1 << n; i++) { bool ok = false; vector<int> t; for(int j = 0; j < n; j++) if(i >> j & 1) t.push_back(j); for(int j = 0; j < 1 << (int)t.size(); j++) { long s = 0; for(int k = 0; k < (int)t.size(); k++) { if(j >> k & 1) s += a[t[k]]/2; else s += a[t[k]]; } ok |= s == w; if(ok)break; } ans += ok; } cout << ans << "\n"; }