結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2021-10-08 22:00:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 3,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 1,918 ms |
コンパイル使用メモリ | 192,924 KB |
最終ジャッジ日時 | 2025-01-24 22:04:23 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int N,W;cin >> N >> W;vector<int>a(N);for(int i = 0; i < N; i++) {cin >> a[i];}int ans = 0;for(int i = 1; i < (1 << N); i++) {bool flag = false;for(int j = i; j >= 0; j--) {j &= i;long long cnt = 0;for(int k = 0; k < N; k++) {if(1 & (i >> k)) {if(1 & (j >> k)) {cnt += a[k]/2;}else {cnt += a[k];}}}if(cnt == W) {flag = true;break;}}if(flag) {ans++;}}cout << ans << endl;}