結果
| 問題 | No.1701 half price |
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-10-08 21:56:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 3,000 ms |
| コード長 | 1,391 bytes |
| コンパイル時間 | 1,228 ms |
| コンパイル使用メモリ | 117,712 KB |
| 最終ジャッジ日時 | 2025-01-24 21:58:53 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n, w; cin >> n >> w;
vector<ll> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
auto ok = [&](int s){
vector<int> v;
for(int i = 0; i < n; i++){
if(s&(1<<i)) v.push_back(i);
}
int m = v.size();
for(int t = 0; t < (1<<m); t++){
ll sum = 0;
for(int i = 0; i < m; i++){
if(t&(1<<i)) sum += a[v[i]]/2;
else sum += a[v[i]];
}
if(sum == w) return true;
}
return false;
};
int ans = 0;
for(int s = 1; s < (1<<n); s++){
if(ok(s)) ans++;
}
cout << ans << endl;
}
milanis48663220