結果

問題 No.178 美しいWhitespace (1)
ユーザー togaerror
提出日時 2015-04-11 17:59:15
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 13,952 KB
最終ジャッジ日時 2024-07-04 13:38:43
合計ジャッジ時間 7,881 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
	}
}

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

exit;
0