結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2018-10-31 14:29:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 140 ms / 5,000 ms |
コード長 | 865 bytes |
コンパイル時間 | 2,440 ms |
コンパイル使用メモリ | 77,960 KB |
実行使用メモリ | 54,300 KB |
最終ジャッジ日時 | 2024-11-19 12:20:07 |
合計ジャッジ時間 | 5,759 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
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 I[]= {g,c,p}; int Y[]=new int[3]; int sc=0; for(int i=0;i<s.length();i++) { char y=s.charAt(i); if(y=='G')Y[0]++; else if(y=='C')Y[1]++; else Y[2]++; } for(int i=0;i<3;i++) { int yi=i+1; if(yi==3)yi=0; if(I[i]<=Y[yi]) { sc+=I[i]*3; Y[yi]-=I[i]; I[i]=0; } else { sc+=Y[yi]*3; I[i]-=Y[yi]; Y[yi]=0; } } for(int i=0;i<3;i++) { int yi=i; if(yi==3)yi=0; if(I[i]<=Y[yi]) { sc+=I[i]; Y[yi]-=I[i]; I[i]=0; } else { sc+=Y[yi]; I[i]-=Y[yi]; Y[yi]=0; } } System.out.println(sc); } }