結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2022-12-12 07:01:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 171 ms / 3,000 ms |
コード長 | 664 bytes |
コンパイル時間 | 705 ms |
コンパイル使用メモリ | 77,800 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-06 06:44:23 |
合計ジャッジ時間 | 2,170 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>#include <set>using namespace std;using ll = long long;int main(){int n, w; cin >> n >> w;vector<int> a(n);for(auto &it: a) cin >> it;set<int> mem;int lim = 1;for(int i = 0; i < n; i++) lim *= 3;for(int bit = 1; bit < lim; bit++){ll tot = 0;int bit1 = bit;int mask = 0;for(int i = 0; i < n; i++, bit1 /= 3){if(bit1%3 == 0) continue;mask |= 1 << i;if(bit1%3 == 1) tot += a[i];else tot += a[i]/2;}if(tot == w) mem.emplace(mask);}cout << mem.size() << endl;return 0;}