結果

問題 No.161 制限ジャンケン
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-28 13:07:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 955 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 73,736 KB
実行使用メモリ 56,188 KB
最終ジャッジ日時 2023-08-20 04:58:20
合計ジャッジ時間 5,425 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,740 KB
testcase_01 AC 121 ms
55,756 KB
testcase_02 AC 121 ms
55,512 KB
testcase_03 AC 121 ms
56,000 KB
testcase_04 AC 123 ms
53,800 KB
testcase_05 AC 121 ms
55,464 KB
testcase_06 AC 123 ms
55,768 KB
testcase_07 AC 120 ms
55,872 KB
testcase_08 AC 122 ms
55,960 KB
testcase_09 AC 123 ms
55,476 KB
testcase_10 AC 122 ms
55,740 KB
testcase_11 AC 119 ms
55,820 KB
testcase_12 AC 123 ms
56,080 KB
testcase_13 AC 125 ms
55,960 KB
testcase_14 AC 123 ms
54,328 KB
testcase_15 AC 123 ms
56,172 KB
testcase_16 AC 122 ms
55,688 KB
testcase_17 AC 120 ms
56,132 KB
testcase_18 AC 124 ms
56,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] yuki_GCP = new int [3];
        for(int i=0; i<3; i++){
            yuki_GCP[i]=sc.nextInt();
        }
        String S = sc.next();
        int [] friend_GCP = new int [3];
        for(int i=0; i<S.length(); i++){
            int a = S.charAt(i);
            if(a=='G'){friend_GCP[0]++;}
            if(a=='C'){friend_GCP[1]++;}
            if(a=='P'){friend_GCP[2]++;}
        }
        int win=0;
        int draw=0;
        for(int i=0; i<3; i++){
            int t = Math.min(yuki_GCP[i],friend_GCP[(i+1)%3]);
            win+=t;
            yuki_GCP[i%3]-=t;
            friend_GCP[(i+1)%3]-=t;
        }
        for(int i=0; i<3; i++){
            int t = Math.min(yuki_GCP[i],friend_GCP[i]);
            draw+=t;
        }
        int point = 3*win + draw;
        System.out.println(point);
    }
}
0