結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2016-11-28 13:07:42 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 141 ms / 5,000 ms |
コード長 | 955 bytes |
コンパイル時間 | 3,053 ms |
コンパイル使用メモリ | 77,372 KB |
実行使用メモリ | 54,364 KB |
最終ジャッジ日時 | 2024-11-30 05:07:14 |
合計ジャッジ時間 | 6,511 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int [] yuki_GCP = new int [3];for(int i=0; i<3; i++){yuki_GCP[i]=sc.nextInt();}String S = sc.next();int [] friend_GCP = new int [3];for(int i=0; i<S.length(); i++){int a = S.charAt(i);if(a=='G'){friend_GCP[0]++;}if(a=='C'){friend_GCP[1]++;}if(a=='P'){friend_GCP[2]++;}}int win=0;int draw=0;for(int i=0; i<3; i++){int t = Math.min(yuki_GCP[i],friend_GCP[(i+1)%3]);win+=t;yuki_GCP[i%3]-=t;friend_GCP[(i+1)%3]-=t;}for(int i=0; i<3; i++){int t = Math.min(yuki_GCP[i],friend_GCP[i]);draw+=t;}int point = 3*win + draw;System.out.println(point);}}