結果
問題 | No.1701 half price |
ユーザー |
|
提出日時 | 2021-10-08 22:53:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,286 ms / 3,000 ms |
コード長 | 775 bytes |
コンパイル時間 | 1,567 ms |
コンパイル使用メモリ | 71,396 KB |
最終ジャッジ日時 | 2025-01-24 23:06:43 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>using namespace std;typedef long long ll;int main(void){ll N, W;cin >> N >> W;vector<ll> A(N);for(int i = 0; i < N; i++){cin >> A[i];}ll ans = 0;for(int p = 1; p < (1 << N); p++){for(int p2 = 0; p2 < (1 << N); p2++){ll s = 0;for(int i = 0; i < N; i++){int idx = (p >> i) & 1;int idx2 = (p2 >> i) & 1;if (idx & idx2){s += A[i] / 2;}else if (idx){s += A[i];}}if (s == W){ans++;break;}}}cout << ans << endl;}