結果
| 問題 |
No.1538 引きこもりさんは引き算が得意。
|
| コンテスト | |
| ユーザー |
logx
|
| 提出日時 | 2021-06-06 02:31:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,693 bytes |
| コンパイル時間 | 2,606 ms |
| コンパイル使用メモリ | 192,740 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-23 01:33:48 |
| 合計ジャッジ時間 | 6,400 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 RE * 20 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:73:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
73 | auto [val,p,m]=vec[j];
| ^
main.cpp:78:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
78 | for(auto [val,p,m]:vec){
| ^
ソースコード
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)
/*---------type/const---------*/
const int big=1000000007;
//const int big=998244353;
const double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char newl='\n';
struct{
constexpr operator int(){return -int(1e9)-10;}
constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
constexpr operator int(){return int(1e9)+10;}
constexpr operator ll(){return ll(1e18)+10;}
constexpr auto operator -(){return neginf;}
}inf;
/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif
/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}
int main(){
//std::ios::sync_with_stdio(false);
//std::cin.tie(nullptr);
std::cout.precision(10);
/*------------------------------------*/
int n,k;cin >> n >> k;
vector<int> a(n);
rep(i,n)cin >> a[i];
vector<tuple<long long,int,int>> vec={{0,0,0}};
vec.reserve(exp(3,n));
rep(i,n){
int sz=vec.size();
rep(j,sz){
auto [val,p,m]=vec[j];
vec.emplace_back(val+a[i],p+1,m);
vec.emplace_back(val-a[i],p,m+1);
}
}
for(auto [val,p,m]:vec){
if((p==1 && m==0) || (p && m))if(val==k){
cout << "Yes" << newl;
return 0;
}
}
cout << "No" << newl;
return 0;
}
logx