結果

問題 No.161 制限ジャンケン
ユーザー リチウムリチウム
提出日時 2015-03-05 23:43:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 886 bytes
コンパイル時間 3,282 ms
コンパイル使用メモリ 78,108 KB
実行使用メモリ 41,432 KB
最終ジャッジ日時 2024-05-07 11:53:35
合計ジャッジ時間 6,332 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
41,432 KB
testcase_01 AC 106 ms
40,192 KB
testcase_02 AC 105 ms
40,480 KB
testcase_03 AC 110 ms
41,268 KB
testcase_04 AC 110 ms
40,876 KB
testcase_05 AC 100 ms
40,104 KB
testcase_06 AC 112 ms
40,992 KB
testcase_07 AC 102 ms
40,132 KB
testcase_08 AC 112 ms
40,824 KB
testcase_09 AC 115 ms
41,384 KB
testcase_10 AC 110 ms
39,952 KB
testcase_11 AC 107 ms
40,464 KB
testcase_12 AC 112 ms
40,908 KB
testcase_13 AC 116 ms
41,260 KB
testcase_14 AC 115 ms
41,004 KB
testcase_15 AC 104 ms
39,832 KB
testcase_16 AC 116 ms
39,968 KB
testcase_17 AC 111 ms
41,360 KB
testcase_18 AC 114 ms
41,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class yukicoder {
	public static void dfs(int map[][],int p,int now,int lim,ArrayList<Integer> a){
		
	}
	
	
	public static void main(String args[]) {
			Scanner sc=new Scanner(System.in);
			int g=sc.nextInt();
		    int c=sc.nextInt();
		    int p=sc.nextInt();
		    char a[]=sc.next().toCharArray();
		    int ge=0;
		    int ce=0;
		    int pe=0;
		    for(int i=0;i<a.length;i++){
		    	if(a[i]=='G')ge++;
		    	else if(a[i]=='C')ce++;
		    	else pe++;
		    }
		    int ans=0;
		    
		    int G=Math.min(g,ce);
		    ans+=G*3;
		    g-=G;
		    ce-=G;
		    
		    int C=Math.min(c,pe);
		    ans+=C*3;
		    c-=C;
		    pe-=C;
		    
		    int P=Math.min(p,ge);
		    ans+=P*3;
		    p-=P;
		    ge-=P;
		    
		    ans+=Math.min(g,ge)+Math.min(c,ce)+Math.min(p,pe);
		    		
		    System.out.println(ans);
	}

}
0