結果

問題 No.178 美しいWhitespace (1)
ユーザー togaerrortogaerror
提出日時 2015-04-11 18:01:56
言語 Perl
(5.38.2)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 11,052 KB
実行使用メモリ 12,408 KB
最終ジャッジ日時 2023-09-17 19:18:16
合計ジャッジ時間 5,723 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
11,032 KB
testcase_01 AC 41 ms
11,288 KB
testcase_02 AC 41 ms
11,108 KB
testcase_03 AC 41 ms
11,188 KB
testcase_04 AC 230 ms
12,088 KB
testcase_05 AC 235 ms
12,076 KB
testcase_06 AC 230 ms
12,312 KB
testcase_07 AC 138 ms
12,172 KB
testcase_08 AC 229 ms
12,244 KB
testcase_09 AC 230 ms
12,080 KB
testcase_10 AC 231 ms
12,156 KB
testcase_11 AC 140 ms
12,076 KB
testcase_12 AC 139 ms
12,364 KB
testcase_13 AC 228 ms
12,280 KB
testcase_14 AC 231 ms
12,392 KB
testcase_15 AC 232 ms
12,276 KB
testcase_16 AC 228 ms
12,200 KB
testcase_17 AC 230 ms
12,332 KB
testcase_18 AC 140 ms
12,064 KB
testcase_19 AC 230 ms
12,108 KB
testcase_20 AC 139 ms
12,184 KB
testcase_21 AC 231 ms
12,408 KB
testcase_22 AC 201 ms
11,776 KB
testcase_23 AC 207 ms
11,940 KB
testcase_24 AC 212 ms
12,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;
use bigint;

my $n = <>;
my @arraya;
my @arrayb;
my @count;
for(my $i = 0; $i < $n; $i++) {
	($arraya[$i], $arrayb[$i] )= split / /, <>;
	$count[$i] = $arraya[$i] + 4 * $arrayb[$i];
}

@count = reverse sort {$a <=> $b} @count;
my $ans = 0;

for(my $i = 1; $i < $n; $i++) {
	if(($count[0] - $count[$i]) % 2 eq 0) {
		my $c = $count[0] - $count[$i];
		$ans += $c / 2;
	} else {
		$ans = -1;
		last;
	}
}

if($ans  < 0) {
	print "$ans\n";
} else {
	print "$ans\n";
}

exit;
0