結果

問題 No.135 とりあえず1次元の問題
ユーザー togaerror
提出日時 2015-05-03 18:03:44
言語 Perl
(5.40.0)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 525 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 5,760 KB
実行使用メモリ 27,704 KB
最終ジャッジ日時 2025-01-03 05:40:38
合計ジャッジ時間 2,168 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/evn perl

use strict;
use warnings;

my $n = <>;
my $x = <>;
chomp $x;
my @array = split / /, $x;
@array = sort {$a <=> $b} @array;
my @after;
my $j = 0;
$after[0] = $array[0];
for(my $i = 1; $i < $n; $i++) {
	if($after[$j]  != $array[$i]) {
		$j++;
		$after[$j] = $array[$i];
	}
}

my $ans;
if($#after >= 1) {
	$ans = $after[1] - $after[0];
	for(my $i = 0; $i < $#after; $i++) {
		if($after[$i + 1] - $after[$i] < $ans) {
			$ans = $after[$i + 1] - $after[$i];
		}
	}
} else {
	$ans = 0;
}

print "$ans\n";

exit;
0