結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,740 KB
testcase_01 AC 5 ms
4,884 KB
testcase_02 AC 5 ms
5,008 KB
testcase_03 AC 5 ms
4,992 KB
testcase_04 AC 7 ms
5,228 KB
testcase_05 AC 7 ms
5,284 KB
testcase_06 AC 6 ms
4,972 KB
testcase_07 WA -
testcase_08 AC 6 ms
5,148 KB
testcase_09 AC 7 ms
5,028 KB
testcase_10 AC 7 ms
5,020 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
5,000 KB
testcase_14 AC 7 ms
5,004 KB
testcase_15 AC 6 ms
5,148 KB
testcase_16 AC 7 ms
5,176 KB
testcase_17 AC 7 ms
5,024 KB
testcase_18 WA -
testcase_19 AC 7 ms
5,084 KB
testcase_20 AC 7 ms
5,260 KB
testcase_21 AC 7 ms
5,148 KB
testcase_22 AC 6 ms
5,252 KB
testcase_23 AC 7 ms
5,004 KB
testcase_24 AC 6 ms
5,028 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 eq 0) {
		my $c = $count[0] - $count[$i];
		$ans += $c / 2;
	} else {
		$ans = -1;
	}
}

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

exit;
0