結果
| 問題 | No.1538 引きこもりさんは引き算が得意。 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-06 20:19:43 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,127 bytes |
| 記録 | |
| コンパイル時間 | 4,064 ms |
| コンパイル使用メモリ | 216,672 KB |
| 最終ジャッジ日時 | 2025-01-22 04:30:11 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 WA * 4 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,K; cin >> n >> K;
vector<ll> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
}
vector<ll> sum;
bool ok=false;
for(int i=1;i<(1<<n)-1;i++){
if(__builtin_popcount(i)==1)continue;
ll s=0;
for(int j=0;j<n;j++){
if((1<<j)&i){
s+=a[j];
}
}
sum.push_back(s);
for(int j=0;j<n;j++){
if((1<<j)&i)continue;
if(s-a[j]==abs(K)){
ok=true;
}
}
}
sort(sum.begin(), sum.end());
int cnt=0;
for(int i=0;i<sum.size();i++){
ll u=sum[i]-K;
int id=lower_bound(sum.begin(), sum.end(),u)-sum.begin();
if(sum[id]==u){
ok=true;
}
}
if(ok)printf("Yes\n");
else printf("No\n");
}