//#define _GLIBCXX_DEBUG #include /*多倍長整数 #include #include namespace mp = boost::multiprecision; // 任意長整数型 using Bint = mp::cpp_int; //仮数部が10進数で1024桁の浮動小数点数型(TLEしたら小さくする) using Real = mp::number>; */ using namespace std; using ll=long long; using ull=unsigned long long; using ld=long double; using P=pair; const ll INF=1e17; const vector dx={0,0,1,-1,1,1,-1,-1}; const vector dy={1,-1,0,0,1,-1,-1,1}; const vector dirs={'>','<','v','^'}; #define rep1(a) for(ll i = 0; i < a; ++i) #define rep2(i, a) for(ll i = 0; i < a; ++i) #define rep3(i, a, b) for(ll i = a; i < b; ++i) #define rep4(i, a, b, c) for(ll i = a; i < b; i += c) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() template ostream& operator<<(ostream &os,pair &pai){ return os<<"("< ostream& operator<<(ostream &os,vector vec){ for(auto val:vec){ os< istream& operator>>(istream &is,pair &pai){ is>>pai.first>>pai.second; return is; } template istream& operator>>(istream &is,vector &vec){ for(int i=0;i<(int)vec.size();i++){ is>>vec[i]; } return is; } void set_cout(){ cout< void print(const T &vec){ int i=0; for(auto val:vec){ cout< void print2(const vector> &vec){ int i=0; for(auto v:vec){ cout< void chmin(T &a,T b){ if(a>b){ a=b; } return; } template void chmax(T &a,T b){ if(a(const ob3 &o) const{ return a>o.a; } }; struct UnionFind{ int N; vector par,rank,siz; int cnt; UnionFind(int n){ assert(0<=n); N=n; par.resize(N,-1); rank.resize(N,0); siz.resize(N,1); cnt=n; } int leader(int x){ assert(0<=x && x> groups(){ vector> member(N); for(int v=0;v> res; for(int v=0;v>N>>S>>T>>K; S--;T--; vector A(N); cin>>A; UnionFind uf(N); int minApos=min_element(all(A))-A.begin(); rep(i,N){ if(A[i]+A[minApos]<=K){ uf.merge(i,minApos); } } if(uf.same(S,T)){ if(A[S]+A[T]<=K){ cout<<1; }else{ cout<<2; } }else{ cout<<-1; } } int main(){ cin.tie(0)->sync_with_stdio(0); int T=1; //cin>>T; while(T--){ solve(); } }