結果

問題 No.135 とりあえず1次元の問題
ユーザー togaerror
提出日時 2015-03-25 19:07:38
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2025-01-03 05:30:48
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

my $n = <>;
my $str = <>;
chomp $str;
my @array = split / /, $str;
my $ans = $array[1] - $array[0];
@array = sort {$a <=> $b} @array;
if($n < 3) {
	print "0\n";
} else {
	for(my $i = 0; $i < $n - 1; $i++) {
		my $com = $array[$i + 1] - $array[$i];
		if(($com < $ans)and($com > 0)) {
			$ans = $com;
		}
	}
	print "$ans\n";
}

exit;
0