結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
tsunatama5
|
| 提出日時 | 2015-02-04 20:04:33 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,059 bytes |
| コンパイル時間 | 4,395 ms |
| コンパイル使用メモリ | 77,204 KB |
| 実行使用メモリ | 58,740 KB |
| 最終ジャッジ日時 | 2025-01-03 05:14:07 |
| 合計ジャッジ時間 | 11,387 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 22 |
ソースコード
package P135;
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
public class P135 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String n = sc.nextLine();
int nint = Integer.parseInt(n);
String l = sc.nextLine();
String[] lstrs = l.split(" ");
int lint[] = new int[100000];
int i = 0;
int max = nint - 1;
for (i=0;i<=max;i++) {
lint[i] = Integer.parseInt(lstrs[i]);
}
int j;
int temp = 0;
int ans = 1000000;
Arrays.sort(lint);
System.out.println(Arrays.toString(lint));
for (i=1;i<=max;i++) {
temp = Math.abs(lint[i-1] - lint[i]);
if (ans > temp && lint[i] != lint[i-1]) {
ans = temp;
// System.out.printf("%d %d %d %d\n",i,lint[i],lint[i-1],temp);
}
}
/*
for (i=0;i<=max;i++) {
for (j=i;j<=max;j++) {
temp = Math.abs(lint[i]-lint[j]);
if (ans > temp && lint[i] != lint[j]) {
ans = temp;
System.out.printf("%d %d %d %d %d\n",i,lint[i],j,lint[j],temp);
}
}
}
*/
System.out.println(ans);
}
}
tsunatama5