結果

問題 No.161 制限ジャンケン
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-13 13:25:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 1,659 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 74,612 KB
実行使用メモリ 56,068 KB
最終ジャッジ日時 2023-08-20 04:27:26
合計ジャッジ時間 5,567 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,856 KB
testcase_01 AC 126 ms
55,932 KB
testcase_02 AC 130 ms
55,736 KB
testcase_03 AC 124 ms
55,888 KB
testcase_04 AC 125 ms
55,740 KB
testcase_05 AC 127 ms
56,068 KB
testcase_06 AC 128 ms
55,948 KB
testcase_07 AC 124 ms
55,760 KB
testcase_08 AC 129 ms
55,608 KB
testcase_09 AC 124 ms
55,764 KB
testcase_10 AC 126 ms
55,860 KB
testcase_11 AC 126 ms
55,772 KB
testcase_12 AC 127 ms
55,572 KB
testcase_13 AC 128 ms
55,596 KB
testcase_14 AC 127 ms
55,756 KB
testcase_15 AC 126 ms
55,468 KB
testcase_16 AC 126 ms
55,600 KB
testcase_17 AC 126 ms
55,708 KB
testcase_18 AC 127 ms
56,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int gi = koko.nextInt();
        int ci = koko.nextInt();
        int pi = koko.nextInt();
        int gy = 0;
        int cy = 0;
        int py = 0;
        String s = koko.next();
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='G'){
                gy++;
            }else if(s.charAt(i)=='C'){
                cy++;
            }else{
                py++;
            }
        }
        int gp=0; 
        int cp=0;
        int pp=0; 
        int gr=0; 
        int cr=0; 
        int pr=0; 
        int rp=0;
        if(pi>=gy){
            pp=3*gy;
            pr=pi-gy;
            if(ci>=py){
                cp=3*py;
                cr=ci-py;
                gp=3*gi;
                rp=cr;
            }else if(ci<py){
                cp=3*ci;
                if(pr>=(py-ci)){
                    rp=(py-ci);
                    gp=3*gi;
                }else if(pr<(py-ci)){
                    rp=pr;
                    gp=3*cy;
                }
            }
        }else if(pi<gy){
            pp=3*pi;
            if(gi>=cy){
                gp=3*cy;
                gr=gi-cy;
                if(gr>=(gy-pi)){
                    rp=gy-pi;
                    cp=3*ci;
                }else if(gr<(gy-pi)){
                    rp=gr;
                    cp=3*py;
                }
            }else if(gi<cy){
                gp=3*gi;
                cp=3*py;
                rp=cy-gi;
            }
        }
        System.out.println(gp+cp+pp+rp);
    }
}
0