結果
| 問題 |
No.3252 Constrained Moving
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-05 22:02:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 545 bytes |
| コンパイル時間 | 2,929 ms |
| コンパイル使用メモリ | 278,388 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-09-05 22:02:46 |
| 合計ジャッジ時間 | 5,069 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e18;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,s,t,k;cin>>n>>s>>t>>k;
s--;t--;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
if(a[s]>k||a[t]>k){
cout<<-1<<endl;
return 0;
}
if(a[s]+a[t]<=k){
cout<<1<<endl;
return 0;
}
auto it=min_element(a.begin(),a.end());
if(a[s]+*it<=k&&*it+a[t]<=k){
cout<<2<<endl;
}else{
cout<<-1<<endl;
}
}