結果

問題 No.161 制限ジャンケン
ユーザー togaerrortogaerror
提出日時 2015-06-29 16:51:03
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 5,220 KB
実行使用メモリ 5,084 KB
最終ジャッジ日時 2023-09-22 04:24:33
合計ジャッジ時間 1,417 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 4 ms
4,912 KB
testcase_02 AC 5 ms
4,844 KB
testcase_03 AC 5 ms
4,856 KB
testcase_04 WA -
testcase_05 AC 4 ms
5,032 KB
testcase_06 AC 5 ms
5,040 KB
testcase_07 AC 5 ms
4,816 KB
testcase_08 AC 5 ms
5,048 KB
testcase_09 AC 5 ms
4,980 KB
testcase_10 AC 5 ms
5,084 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 5 ms
4,912 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use strict;
use warnings;

my ($g, $c, $p) = split / /, <>;
my $s = <>;
chomp $s;
my @sa = split //, $s;
my $total = 0;
for(my $i = 0; $i < $#sa + 1; $i++) {
	if($sa[$i] eq 'G') {
		if($p > 0) {
			$total += 3;
			$p--;
		} elsif($g > 0) {
			$total++;
			$g--;
		} else {
			$c--;
		}
	} elsif($sa[$i] eq 'C') {
		if($g > 0) {
			$total += 3;
			$g--;
		} elsif($c > 0) {
			$total++;
			$c--;
		} else {
			$p--;
		}
	} else {
		if($c > 0) {
			$total += 3;
			$c--;
		} elsif($p > 0) {
			$total++;
			$p--;
		} else {
			$g--;
		}
	}
}

print "$total\n";

exit;
0