結果
| 問題 |
No.1701 half price
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2021-10-08 22:29:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 772 bytes |
| コンパイル時間 | 2,031 ms |
| コンパイル使用メモリ | 177,032 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-23 05:12:49 |
| 合計ジャッジ時間 | 3,209 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
int main(){
ll n,w;
cin >> n >> w;
vector<ll> a(n);
rep(i,n) cin >> a[i];
ll ans = 0;
rep(i,pow(2,n)){
ll tot = 0;
set<ll> dec, dec2;
dec.insert(0); dec2.insert(0);
int x = i, j = 0;
while(x){
if(x%2){
tot += a[j];
for(ll y:dec){
dec2.insert(y+a[j]/2);
}
dec = dec2;
}
j++;
x /= 2;
}
ans += dec.count(tot - w);
}
cout << ans << endl;
return 0;
}
houren