結果
| 問題 |
No.716 距離
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-29 11:53:55 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 196 ms / 2,000 ms |
| コード長 | 704 bytes |
| コンパイル時間 | 3,534 ms |
| コンパイル使用メモリ | 74,944 KB |
| 実行使用メモリ | 42,464 KB |
| 最終ジャッジ日時 | 2024-07-08 13:29:14 |
| 合計ジャッジ時間 | 11,886 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 |
ソースコード
import java.util.*;
public class distance{
public static int calculate_max(int[] A){
return A[A.length-1] - A[0];
}
public static int calculate_min(int[] A){
int min_dis = calculate_max(A);
try{
for (int i = 0; i<A.length-1; i++){
if (A[i+1]-A[i] < min_dis) {min_dis = A[i+1]-A[i];}
}
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
return min_dis;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// Read input
int N = sc.nextInt();
int A[];
A = new int[N];
for (int i = 0; i<N; i++){
A[i] = sc.nextInt();
}
// Make output
System.out.println(calculate_min(A));
System.out.println(calculate_max(A));
}
}