結果

問題 No.161 制限ジャンケン
ユーザー hhgfhn1
提出日時 2018-10-31 14:01:00
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 2,453 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 54,484 KB
最終ジャッジ日時 2024-11-19 12:14:24
合計ジャッジ時間 6,127 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int g=scanner.nextInt();
		int c=scanner.nextInt();
		int p=scanner.nextInt();
		String s=scanner.next();
		int x[]= {g,c,p};
		int sc=0;
		for(int i=0;i<s.length();i++) {
			char y=s.charAt(i);
			int tar=0;
			if(y=='G')tar=2;
			else if(y=='C')tar=0;
			else tar=1;
			int cnt=0;
			while(x[tar]==0) {
				tar++;
				if(tar==3)tar=0;
				cnt++;
			}
			x[tar]--;
			if(cnt==0)sc+=3;
			else if(cnt==1)sc++;
		}
		System.out.println(sc);
	}
}
0