結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-05 23:31:03 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 122 ms / 5,000 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 2,211 ms |
コンパイル使用メモリ | 81,436 KB |
実行使用メモリ | 41,568 KB |
最終ジャッジ日時 | 2024-11-30 04:24:38 |
合計ジャッジ時間 | 5,079 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListSet; public class Main { public static final int C = 1000000007; static final int CY = 1000000000; //static boolean MAP[][]; static int N; static int X; static double P; static String S; static int M; static int MAX = -1; //static int tic[][]; //static String S[]; static long A[]; static double W[]; //static int max; static long DP[]; static int ST[][]; static ConcurrentSkipListSet<Integer> TS; static ArrayList<Integer> AL; public static void main(String[] args) { StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int[] gcp = new int[3]; gcp[0] = sc.nextInt(); gcp[1] = sc.nextInt(); gcp[2] = sc.nextInt(); String str = sc.next(); int[] fgcp = new int[3]; for (int i=0; i < str.length(); i++) { char c = str.charAt(i); if (c == 'G') fgcp[0]++; if (c == 'C') fgcp[1]++; if (c == 'P') fgcp[2]++; } long ans = 0; for (int i=0; i < 3; i++) { int f = i+1 == 3? 0:i+1; int num = Math.min(gcp[i], fgcp[f]); gcp[i] -= num; fgcp[f] -= num; ans += num * 3; } for (int i=0; i < 3; i++) { // int f = i+1 == 3? 0:i+1; int num = Math.min(gcp[i], fgcp[i]); gcp[i] -= num; fgcp[i] -= num; ans += num * 1; } System.out.println(ans); } }