結果

問題 No.161 制限ジャンケン
ユーザー naimonon77naimonon77
提出日時 2015-09-20 23:36:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,097 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 57,068 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:42:06
合計ジャッジ時間 1,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)

typedef long long ll;
typedef unsigned long long ull;
typedef long double lb;

/* ここからが本編 */


int main(void)
{
   int i,j,k,l;
   int g1,c1,p1;
   int g2 = 0 ,c2 = 0 ,p2 = 0;
   int ans = 0;
   int max,min;
   char s[305];
   cin >> g1 >> c1 >> p1;
   cin >> s;

   for(i=0;s[i];i++) {
      switch(s[i]) {
      case 'G' : g2++; break;
      case 'C' : c2++; break;
      case 'P' : p2++; break;
      }
   }

   min = g2;
   if(g2 > p1) min = p1;
   ans += min * 3; g2 -= min; p1 -= min;

   min = c2;
   if(c2 > g1) min = g1;
   ans += min * 3; c2 -= min; g1 -= min;

   min = p2;
   if(p2 > c1) min = c1;
   ans += min * 3; p2 -= min; c1 -= min;


   min = g2;
   if(g2 > g1) min = g1;
   ans += min; g2 -= min; g1 -= min;

   min = c2;
   if(c2 > c1) min = c1;
   ans += min; c2 -= min; c1 -= min;

   min = p2;
   if(p2 > p1) min = p1;
   ans += min; p2 -= min; p1 -= min;

   printf("%d\n",ans);
   return 0;
}
0