結果
問題 |
No.3252 Constrained Moving
|
ユーザー |
|
提出日時 | 2025-09-05 21:39:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 1,905 ms |
コンパイル使用メモリ | 194,868 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-05 21:39:37 |
合計ジャッジ時間 | 3,964 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, s, t, k; cin >> n >> s >> t >> k; if(s == t){ cout << "0\n"; return 0; } vector<int> a(n); for(auto &&v : a) cin >> v; s = a[s - 1], t = a[t - 1]; if(s + t <= k){ cout << "1\n"; return 0; } int mn = *min_element(a.begin(), a.end()); if(s + mn <= k && t + mn <= k){ cout << "2\n"; }else{ cout << "-1\n"; } }