結果
| 問題 |
No.1701 half price
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-22 06:22:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 3,000 ms |
| コード長 | 942 bytes |
| コンパイル時間 | 2,004 ms |
| コンパイル使用メモリ | 195,600 KB |
| 最終ジャッジ日時 | 2025-01-31 02:43:37 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ll n,w;
std::cin >> n>>w;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
ll ans = 0;
for (int i = 1; i < (1<<n); i++) {
ll sum = 0;
vector<ll> kon;
for (int j = 0; j < n; j++) {
if(i>>j&1){
sum += a[j];
kon.push_back(a[j]);
}
}
if(sum==w){
ans++;
continue;
}else{
bool ok = false;
for (int j = 0; j < (1<<kon.size()); j++) {
ll sum2 = 0;
for (int k = 0; k < kon.size(); k++) {
if(j>>k&1)sum2+=kon[k]/2;
}
if(sum-sum2==w)ok=true;
}
if(ok)ans++;
}
}
std::cout << ans << std::endl;
}