結果
問題 |
No.1701 half price
|
ユーザー |
![]() |
提出日時 | 2021-10-17 12:43:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 532 bytes |
コンパイル時間 | 1,772 ms |
コンパイル使用メモリ | 170,568 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-17 19:39:55 |
合計ジャッジ時間 | 2,420 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 9 |
ソースコード
#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 l = 1 << N; int ans = 0; for( int mask = 1; mask < l; mask++ ) { vector<int> b; int s = 0; for( int i = 0; i < N; i++ ) { if( mask >> i & 1) { b.push_back( a[i] ); s += a[i]; } } if( s == W ) ans++; else { int n = b.size(); for( int i = 0; i < n; i++ ) { if( s - b[i] / 2 == W ) { ans++; } } } } cout << ans << endl; }