結果

問題 No.135 とりあえず1次元の問題
ユーザー togaerrortogaerror
提出日時 2015-03-31 23:39:50
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 441 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 5,380 KB
実行使用メモリ 18,076 KB
最終ジャッジ日時 2023-09-01 03:16:01
合計ジャッジ時間 7,021 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
18,076 KB
testcase_01 AC 5 ms
4,812 KB
testcase_02 AC 5 ms
5,108 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
evil01.txt -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

my $n = <>;
my $str = <>;
chomp $str;
my @array = split / /, $str;
@array = sort {$a <=> $b} @array;

my $i = 1;
my $min;
my $flag = 0;
while($flag == 0) {
	$min = $array[$i] - $array[$i -1];
	$i++;
	if($min != 0) {
		$flag = 1;
		$i--;
	}
}

for(my $j = $i; $j < $n; $j++) {
	my $move = $array[$j] - $array[$j-1];
	if(($move != 0)and($move < $min)) {
		$min = $move;
	}
}

print "$min\n";

exit;
0