結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
ちよちゃん
|
| 提出日時 | 2016-06-06 22:12:31 |
| 言語 | Java (openjdk 23) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,102 bytes |
| コンパイル時間 | 1,870 ms |
| コンパイル使用メモリ | 78,060 KB |
| 最終ジャッジ日時 | 2024-11-14 19:45:13 |
| 合計ジャッジ時間 | 2,298 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Main.java:6: error: package org.omg.PortableInterceptor does not exist
import org.omg.PortableInterceptor.Interceptor;
^
2 errors
ソースコード
package yukicoder;
import java.util.Arrays;
import java.util.Scanner;
import org.omg.PortableInterceptor.Interceptor;
public class Yuki135 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int x[] = new int[n];
for (int i = 0; i < n; i++) {
x[i] = scan.nextInt();
}
scan.close();
Arrays.sort(x);
int ans = 0;
int ans2 = 0;
for (int i = 0; i < n-1; i++) {
if(x[i] != 0){
if (x[i + 1] > x[i]) {
ans = x[i + 1] - x[i];
} else if(x[i + 1] < x[i]){
ans = x[i] - x[i + 1];
} else if(x[i + 1] == x[i]){
ans = x[i];
}
if(ans2 == 0){
ans2 = ans;
}else if(ans2 > ans && ans != 0){
ans2 = ans;
}
}
}
System.out.println(ans2);
/*
* int ans = 0; int perseAns = 0; for(int i = 0; i < n; i++) { for(int j
* = 0; j < n; j++) {
*
* if( x[i] > x[j] ){ ans = x[i]-x[j]; } else { ans = x[j]-x[i]; }
*
* if(perseAns == 0) { perseAns = ans; }else if ( ans < perseAns && ans
* != 0) { perseAns = ans; } } } System.out.println(perseAns);
*/
}
}
ちよちゃん