結果

問題 No.99 ジャンピング駒
ユーザー togaerrortogaerror
提出日時 2015-04-06 22:11:06
言語 Perl
(5.38.2)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 353 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 16,024 KB
最終ジャッジ日時 2023-09-17 06:19:20
合計ジャッジ時間 1,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
15,976 KB
testcase_01 AC 49 ms
15,960 KB
testcase_02 AC 48 ms
15,980 KB
testcase_03 AC 48 ms
16,024 KB
testcase_04 AC 46 ms
15,944 KB
testcase_05 AC 49 ms
15,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

my $n = <>;
my $str = <>;
chomp $str;
my @array = split / /, $str;
my $a = 0;
my $b = 0;

for(my $i = 0; $i < $n; $i++) {
		if($array[$i] % 2 == 0) {
			$a++;
		} else {
			$b++;
		}
}

if($a == $b) {
	print "0\n";
} elsif($a < $b) {
	print $b - $a;
	print "\n";
} else {
	print $a - $b;
	print "\n";
}

exit;
0