結果

問題 No.161 制限ジャンケン
ユーザー alpha_virginisalpha_virginis
提出日時 2015-03-05 23:45:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 934 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 67,384 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:22:04
合計ジャッジ時間 1,376 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <math.h>

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

long sub1(long* i, long* y) {
  int temp;
  if( *i >= *y ) {
    temp = *y;
    *i -= *y; 
    *y  = 0;    
    return temp;
  }
  else {
    temp = *i;
    *y -= *i; 
    *i  = 0;
    return temp;    
  }
  return 0;
}    

int main() {

  long i, j;

  long ig, ic, ip;
  long yg, yc, yp;
  std::string str;
  long point;

  std::cin >> ig >> ic >> ip;
  std::cin >> str;

  yg = yc = yp = 0;

  for(i = 0; i < str.length(); i++) {
    if(str[i] == 'G') {
      yg++;
    }
    else if(str[i] == 'C') {
      yc++;
    }
    else if(str[i] == 'P') {
      yp++;
    }
  }

  point = 0;

  point += sub1(&ig, &yc) * 3;
  point += sub1(&ic, &yp) * 3;
  point += sub1(&ip, &yg) * 3;
  
  point += sub1(&ig, &yg);
  point += sub1(&ic, &yc);
  point += sub1(&ip, &yp);

  std::cout << point << std::endl;
  
  return 0;
}

0