結果

問題 No.178 美しいWhitespace (1)
ユーザー togaerrortogaerror
提出日時 2015-04-11 17:40:41
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 492 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 5,236 KB
最終ジャッジ日時 2023-09-17 19:17:56
合計ジャッジ時間 1,626 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,932 KB
testcase_01 AC 5 ms
4,752 KB
testcase_02 AC 5 ms
4,892 KB
testcase_03 AC 5 ms
4,780 KB
testcase_04 AC 6 ms
4,972 KB
testcase_05 AC 6 ms
5,140 KB
testcase_06 AC 6 ms
5,164 KB
testcase_07 WA -
testcase_08 AC 6 ms
4,996 KB
testcase_09 AC 7 ms
5,144 KB
testcase_10 AC 6 ms
5,112 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 6 ms
5,100 KB
testcase_14 AC 7 ms
5,080 KB
testcase_15 AC 6 ms
5,104 KB
testcase_16 AC 7 ms
4,972 KB
testcase_17 AC 6 ms
5,232 KB
testcase_18 WA -
testcase_19 AC 7 ms
5,116 KB
testcase_20 AC 6 ms
5,220 KB
testcase_21 AC 6 ms
4,976 KB
testcase_22 AC 7 ms
5,232 KB
testcase_23 AC 6 ms
4,996 KB
testcase_24 AC 6 ms
5,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

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 == 0) {
		my $c = $count[0] - $count[$i];
		$ans += $c / 2;
	} else {
		$ans = -1;
	}
}

if($ans == -1) {
	print "-1\n";
} else {
	print "$ans\n";
}

exit;
0