結果

問題 No.161 制限ジャンケン
ユーザー taipei_stationtaipei_station
提出日時 2017-11-14 16:25:34
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 637 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 58,364 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-16 13:06:37
合計ジャッジ時間 3,208 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 2 ms
4,380 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>


using namespace std;

int main(){
    int g,g2 = 0,c,c2 = 0,p,p2 = 0,n,ans = 0;
    char s[33];
    scanf("%d %d %d\n%s",&g,&c,&p,s);
    
    n = g + c + p;
    
    for(int i = 0;i < n;i++){
        if(s[i] == 'G') g2++;
        else if(s[i] == 'C') c2++;
        else p2++;
    }
    
    int tmp = min(g2,p);
    ans += tmp*3,g2 -= tmp,p -= tmp;
    tmp = min(c2,g),ans += tmp*3,c2 -= tmp,g -= tmp;
    tmp = min(p2,c),ans += tmp*3,p2 -= tmp,c -= tmp;
    ans += (min(g2,g) + min(c2,c) + min(p2,p));
    
    printf("%d\n",ans);
    
    
    return 0;
}
0