結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-06 00:10:53 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 141 ms / 5,000 ms |
コード長 | 940 bytes |
コンパイル時間 | 2,292 ms |
コンパイル使用メモリ | 78,044 KB |
実行使用メモリ | 50,252 KB |
最終ジャッジ日時 | 2024-11-30 04:27:07 |
合計ジャッジ時間 | 5,643 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
import java.util.Arrays;import java.util.Scanner;public class Main {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[] string = sc.next().toCharArray();Arrays.sort(string);sc.close();int oG = 0;int oC = 0;int oP = 0;for (char d : string) {if (d == 'G') {oG++;} else if (d == 'C') {oC++;} else {oP++;}}int point = 0;point += Math.min(G, oC) * 3;point += Math.min(C, oP) * 3;point += Math.min(P, oG) * 3;if (G >= oC) {G -= oC;oC = 0;} else {oC -= G;G = 0;}if (C >= oP) {C -= oP;oP = 0;} else {oP -= C;C = 0;}if (P >= oG) {P -= oG;oG = 0;} else {oG -= P;P = 0;}point += Math.min(G, oG);point += Math.min(C, oC);point += Math.min(P, oP);System.out.println(point);}}