結果
問題 |
No.3252 Constrained Moving
|
ユーザー |
![]() |
提出日時 | 2025-09-05 21:23:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 842 ms / 2,000 ms |
コード長 | 647 bytes |
コンパイル時間 | 5,750 ms |
コンパイル使用メモリ | 76,024 KB |
実行使用メモリ | 58,620 KB |
最終ジャッジ日時 | 2025-09-05 21:24:29 |
合計ジャッジ時間 | 30,239 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int s = sc.nextInt() - 1; int t = sc.nextInt() - 1; int k = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } sc.close(); int min = 1000000007; for (int i = 0; i < n; i++) { if (i != s && i != t) { min = Math.min(min, a[i]); } } if (a[s] + a[t] <= k) { System.out.println(1); } else if (a[s] + min <= k && a[t] + min <= k) { System.out.println(2); } else { System.out.println(-1); } } }