結果
| 問題 |
No.1538 引きこもりさんは引き算が得意。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-06 19:45:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 837 bytes |
| コンパイル時間 | 2,376 ms |
| コンパイル使用メモリ | 213,504 KB |
| 最終ジャッジ日時 | 2025-01-22 04:20:58 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 WA * 1 TLE * 20 |
ソースコード
#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];
}
bool ok=false;
for(int i=1;i<(1<<n);i++){
for(int j=i;j>0;j=(j-1)&i){
ll sum=0;
if(j==i)continue;
for(int k=0;k<n;k++){
if((1<<k)&i){
if((1<<k)&j)sum-=a[k];
else sum+=a[k];
}
}
if(sum==K)ok=true;
}
}
if(ok)printf("Yes\n");
else printf("No\n");
}