結果

問題 No.161 制限ジャンケン
ユーザー kou6839kou6839
提出日時 2015-03-11 22:28:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 388 ms / 5,000 ms
コード長 1,287 bytes
コンパイル時間 2,650 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 58,492 KB
最終ジャッジ日時 2024-05-07 11:56:37
合計ジャッジ時間 6,734 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 197 ms
49,904 KB
testcase_01 AC 106 ms
39,920 KB
testcase_02 AC 114 ms
41,328 KB
testcase_03 AC 133 ms
41,208 KB
testcase_04 AC 110 ms
40,244 KB
testcase_05 AC 126 ms
41,104 KB
testcase_06 AC 388 ms
58,492 KB
testcase_07 AC 131 ms
41,312 KB
testcase_08 AC 367 ms
58,392 KB
testcase_09 AC 133 ms
41,716 KB
testcase_10 AC 208 ms
48,828 KB
testcase_11 AC 177 ms
48,656 KB
testcase_12 AC 160 ms
47,492 KB
testcase_13 AC 322 ms
56,444 KB
testcase_14 AC 249 ms
51,048 KB
testcase_15 AC 266 ms
52,032 KB
testcase_16 AC 169 ms
48,576 KB
testcase_17 AC 168 ms
47,468 KB
testcase_18 AC 187 ms
48,596 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