結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2015-03-05 23:45:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 934 bytes |
| コンパイル時間 | 705 ms |
| コンパイル使用メモリ | 68,924 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 04:25:53 |
| 合計ジャッジ時間 | 1,270 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#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;
}
alpha_virginis