結果

問題 No.161 制限ジャンケン
ユーザー motimoti
提出日時 2018-06-06 01:09:11
言語 Perl
(5.38.2)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 5,284 KB
実行使用メモリ 5,136 KB
最終ジャッジ日時 2023-09-12 22:40:03
合計ジャッジ時間 1,922 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,104 KB
testcase_01 AC 4 ms
4,900 KB
testcase_02 AC 5 ms
5,068 KB
testcase_03 AC 5 ms
4,916 KB
testcase_04 AC 5 ms
4,944 KB
testcase_05 AC 4 ms
5,008 KB
testcase_06 AC 5 ms
4,960 KB
testcase_07 AC 5 ms
5,056 KB
testcase_08 AC 5 ms
4,824 KB
testcase_09 AC 4 ms
4,976 KB
testcase_10 AC 5 ms
4,980 KB
testcase_11 AC 4 ms
4,960 KB
testcase_12 AC 5 ms
4,900 KB
testcase_13 AC 5 ms
5,028 KB
testcase_14 AC 4 ms
4,916 KB
testcase_15 AC 5 ms
5,104 KB
testcase_16 AC 5 ms
4,900 KB
testcase_17 AC 5 ms
5,136 KB
testcase_18 AC 5 ms
4,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my ($g, $c, $p) = split / /, <>; chomp $p;
my $line = <>; chomp $line;
my @sa = split //, $line;
my ($gg, $cc, $pp) = (0, 0, 0);
for my $c (@sa) {
  $gg++ if $c eq 'G';
  $cc++ if $c eq 'C';
  $pp++ if $c eq 'P';
}

my $ans = 0;
my ($mg, $mc, $mp) = ($g < $cc ? $g : $cc, $c < $pp ? $c : $pp, $p < $gg ? $p : $gg);
$ans += $mg * 3;
$ans += $mc * 3;
$ans += $mp * 3;
$g -= $mg;
$c -= $mc;
$p -= $mp;
$gg -= $mp;
$cc -= $mg;
$pp -= $mc;
$ans += $g < $gg ? $g : $gg;
$ans += $c < $cc ? $c : $cc;
$ans += $p < $pp ? $p : $pp;

print $ans, "\n";
0