結果

問題 No.3252 Constrained Moving
ユーザー asmin
提出日時 2025-09-05 21:23:40
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 8,662 ms
コンパイル使用メモリ 214,956 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-05 21:23:58
合計ジャッジ時間 9,752 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;





void solve(){
    int N, S, T, K; cin >> N >> S >> T >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    --S, --T;
    if(A[S] + A[T] <= K){
        cout << 1 << "\n";
        return;
    }
    int s = A[S];
    int t = A[T];
    sort(begin(A), end(A));
    if(s + A[0] <= K && A[0] + t <= K){
        cout << 2 << "\n";
    }else{
        cout << -1 << "\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(10) << fixed;

    int T;
    T = 1;
    //cin >> T;
    for(;T--;) solve();
}

0