結果

問題 No.178 美しいWhitespace (1)
ユーザー togaerrortogaerror
提出日時 2015-04-11 17:59:15
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 11,056 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2023-09-17 19:18:09
合計ジャッジ時間 6,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
11,404 KB
testcase_01 AC 41 ms
11,200 KB
testcase_02 AC 41 ms
11,044 KB
testcase_03 AC 42 ms
11,052 KB
testcase_04 AC 234 ms
12,148 KB
testcase_05 AC 230 ms
12,200 KB
testcase_06 AC 229 ms
12,164 KB
testcase_07 WA -
testcase_08 AC 229 ms
12,196 KB
testcase_09 AC 229 ms
12,192 KB
testcase_10 AC 227 ms
12,204 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 232 ms
12,212 KB
testcase_14 AC 231 ms
12,112 KB
testcase_15 AC 231 ms
12,100 KB
testcase_16 AC 233 ms
12,164 KB
testcase_17 AC 230 ms
12,212 KB
testcase_18 WA -
testcase_19 AC 232 ms
12,164 KB
testcase_20 AC 215 ms
12,104 KB
testcase_21 AC 232 ms
12,156 KB
testcase_22 AC 201 ms
12,032 KB
testcase_23 AC 207 ms
11,888 KB
testcase_24 AC 210 ms
11,896 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;
	}
}

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

exit;
0