結果
問題 | No.2091 Shio Ramen (Easy) |
ユーザー | Asahi |
提出日時 | 2023-01-06 17:22:40 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 1,358 bytes |
コンパイル時間 | 2,540 ms |
コンパイル使用メモリ | 76,184 KB |
実行使用メモリ | 56,200 KB |
最終ジャッジ日時 | 2023-09-12 14:23:14 |
合計ジャッジ時間 | 5,046 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,580 KB |
testcase_01 | AC | 127 ms
55,796 KB |
testcase_02 | AC | 128 ms
55,588 KB |
testcase_03 | AC | 127 ms
55,408 KB |
testcase_04 | AC | 127 ms
55,700 KB |
testcase_05 | AC | 126 ms
55,720 KB |
testcase_06 | AC | 126 ms
55,752 KB |
testcase_07 | AC | 128 ms
55,580 KB |
testcase_08 | AC | 127 ms
55,460 KB |
testcase_09 | AC | 127 ms
55,500 KB |
testcase_10 | AC | 124 ms
55,772 KB |
testcase_11 | AC | 125 ms
55,772 KB |
testcase_12 | AC | 124 ms
56,200 KB |
testcase_13 | AC | 124 ms
55,704 KB |
testcase_14 | AC | 126 ms
55,320 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; public class Main{ public static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); public static final int INFI = Integer.MAX_VALUE; public static final long INFL = Long.MAX_VALUE; public static final int MOD = 1000000007; public static PrintWriter output = new PrintWriter(System.out); public static Scanner sc = new Scanner(System.in); public static final int [] dy4 = {0,1,0,-1}; public static final int [] dx4 = {1,0,-1,0}; public static ArrayList<ArrayList<Integer>> list = new ArrayList<>(); public static ArrayList<Integer> answer = new ArrayList<>(); public static boolean [] visited ; public static void main(String[] args) throws IOException{ StringTokenizer st; //st = new StringTokenizer(buff.readLine()); int N = sc.nextInt(); int S = sc.nextInt(); int K = sc.nextInt(); int [] A = new int[N]; for(int i=0;i<N;i++) A[i] = sc.nextInt(); int min = INFI; int ans = -1; for(int i=0;i<N;i++) { if(Math.abs(A[i] - S) <= K && min > Math.abs(A[i] - S)) { min = Math.abs(A[i]-S); ans = i; } } output.print(ans == -1 ? "Unlucky!":ans+1); output.flush(); } }