結果
| 問題 | No.3252 Constrained Moving | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-09-05 21:50:21 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 608 bytes | 
| コンパイル時間 | 294 ms | 
| コンパイル使用メモリ | 82,292 KB | 
| 実行使用メモリ | 136,384 KB | 
| 最終ジャッジ日時 | 2025-09-05 21:50:33 | 
| 合計ジャッジ時間 | 9,801 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 27 WA * 3 | 
ソースコード
N,S,T,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if N == 2:
    if A[0] + A[1] <= K:
        print(1)
    else:
        print(-1)
    exit()
if A[S-1] + A[T-1] <= K:
    print(1)
    exit()
if min(A) == A[S-1]:
    if A[S-1] + A[T-1] <= K:
        print(1)
    else:
        print(-1)
    
    exit()
a = A[T-1]
res=[]
for i in range(1, N+1):
    res.append([A[i-1], i])
res = sorted(res, key=lambda x: x[0])
if min(A) == a:
    if a + res[1][0] <= K:
        print(2)
    else:
        print(-1)
else:
    if res[0][0] + a <= K:
        print(2)
    else:
        print(-1)
            
            
            
        