結果
問題 | No.161 制限ジャンケン |
ユーザー |
|
提出日時 | 2015-07-10 10:54:23 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 2,328 bytes |
コンパイル時間 | 626 ms |
コンパイル使用メモリ | 55,900 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:45:00 |
合計ジャッジ時間 | 1,374 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
//// main.cpp// Q256//// Created by AkihiroKOBAYASHI on 7/10/15.// Copyright (c) 2015 Akhr5884. All rights reserved.//#include <iostream>#include <string.h>int main(int argc, const char * argv[]) {int te[3];int count = 0;int sum = 0;int point = 0;std::string aite;// char *moji;// int *already;char moji[1000];int already[1000];while(count < 3) {std::cin >> te[count];sum += te[count];count++;}std::cin >> aite;// moji = (char *)malloc( strlen(aite.c_str()) + 1 );// already = (int*)malloc( strlen(aite.c_str()) + 1 );std::sprintf(moji, "%s", aite.c_str());// wincount = 0;while (count < sum) {already[count] = 0;switch(aite[count]) {case 'G':if(te[2] > 0) {te[2]--;point += 3;already[count] = 1;}break;case 'C':if(te[0] > 0) {te[0]--;point += 3;already[count] = 1;}break;case 'P':if(te[1] > 0) {te[1]--;point += 3;already[count] = 1;}break;}count++;}// drawcount = 0;while (count < sum) {if(already[count] != 1) {switch(aite[count]) {case 'G':if(te[0] > 0) {te[0]--;point += 1;already[count] = 1;}break;case 'C':if(te[1] > 0) {te[1]--;point += 1;already[count] = 1;}break;case 'P':if(te[2] > 0) {te[2]--;point += 1;already[count] = 1;}break;}}count++;}std::cout << point << "\n";return 0;}