結果

問題 No.161 制限ジャンケン
ユーザー kou6839kou6839
提出日時 2015-03-11 22:28:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 383 ms / 5,000 ms
コード長 1,287 bytes
コンパイル時間 2,500 ms
コンパイル使用メモリ 87,536 KB
実行使用メモリ 71,396 KB
最終ジャッジ日時 2023-08-20 04:25:21
合計ジャッジ時間 7,625 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
62,500 KB
testcase_01 AC 125 ms
55,840 KB
testcase_02 AC 127 ms
55,868 KB
testcase_03 AC 132 ms
55,500 KB
testcase_04 AC 127 ms
55,948 KB
testcase_05 AC 128 ms
55,972 KB
testcase_06 AC 332 ms
68,552 KB
testcase_07 AC 127 ms
55,504 KB
testcase_08 AC 383 ms
71,396 KB
testcase_09 AC 131 ms
57,788 KB
testcase_10 AC 211 ms
61,692 KB
testcase_11 AC 197 ms
62,328 KB
testcase_12 AC 182 ms
61,044 KB
testcase_13 AC 380 ms
68,740 KB
testcase_14 AC 239 ms
63,844 KB
testcase_15 AC 311 ms
62,840 KB
testcase_16 AC 208 ms
62,560 KB
testcase_17 AC 196 ms
61,844 KB
testcase_18 AC 195 ms
61,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.beans.IntrospectionException;
import java.util.*;

class Main {
	static int jan(int g,int c,int p){
		if(g==0 && c ==0 && p==0)return 0;
		if(dp[g][c][p]>0)return dp[g][c][p];
		int res = 0;
		if(g>0){
			res = Math.max(res, jan(g-1, c, p)+ja[gu][Integer.parseInt(te.charAt(te.length()-g-c-p)+"")]);
		}
		if(c>0){
			res = Math.max(res, jan(g, c-1, p)+ja[tyo][Integer.parseInt(te.charAt(te.length()-g-c-p)+"")]);
		}
		if(p>0){
			res = Math.max(res, jan(g, c, p-1)+ja[pa][Integer.parseInt(te.charAt(te.length()-g-c-p)+"")]);
		}
		return dp[g][c][p]=res;
		
	}
	static int[][][] dp;
	static int gu = 0;
	static int tyo = 1;
	static int pa = 2;
	static int[][] ja = new int[3][3];
	static String te;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int g = sc.nextInt();
		int c = sc.nextInt();
		int p = sc.nextInt();
		String temp = sc.next();
		for(int i=0;i<temp.length();i++){
			if(temp.charAt(i)=='G'){
				te+=0;
			}else if(temp.charAt(i)=='C'){
				te+=1;
				
			}else{
				te+=2;
			}
		}
		int ans =0 ;
		ja[gu][gu]=1;
		ja[gu][tyo]=3;
		ja[gu][pa]=0;
		ja[tyo][gu]=0;
		ja[tyo][tyo]=1;
		ja[tyo][pa]=3;
		ja[pa][gu]=3;
		ja[pa][tyo]=0;
		ja[pa][pa]=1;
		dp = new int[g+1][c+1][p+1];
		System.out.println(jan(g, c, p));
	}
}
0