結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー | TwinkleStar74 |
提出日時 | 2017-10-10 00:50:59 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 930 bytes |
コンパイル時間 | 3,225 ms |
コンパイル使用メモリ | 83,668 KB |
実行使用メモリ | 53,560 KB |
最終ジャッジ日時 | 2024-04-28 14:32:19 |
合計ジャッジ時間 | 6,474 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 340 ms
53,560 KB |
testcase_01 | AC | 44 ms
37,060 KB |
testcase_02 | AC | 45 ms
36,636 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 50 ms
37,112 KB |
testcase_13 | AC | 46 ms
37,088 KB |
testcase_14 | AC | 49 ms
36,908 KB |
testcase_15 | AC | 47 ms
37,048 KB |
testcase_16 | WA | - |
testcase_17 | AC | 51 ms
36,988 KB |
testcase_18 | AC | 45 ms
36,776 KB |
testcase_19 | AC | 48 ms
36,888 KB |
testcase_20 | AC | 52 ms
37,420 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
evil01.txt | AC | 286 ms
52,184 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; public class No135{ public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(); try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String n = br.readLine(); String[] str = br.readLine().split(" "); for(int i=0; i < str.length; i++) list.add(Integer.parseInt(str[i])); Collections.sort(list); System.out.println(getAns(list)); } catch(IOException e){ e.getStackTrace(); } catch(NumberFormatException e){ e.getStackTrace(); } } public static int getAns(ArrayList<Integer> a){ int ans = 100000000; for(int i= 2; i< a.size(); i++){ if(a.get(i) == a.get(i-1)) continue; else if(ans > (a.get(i) - a.get(i-1))) ans = a.get(i) - a.get(i-1); } return ans; } }