結果
| 問題 | No.131 マンハッタン距離 | 
| コンテスト | |
| ユーザー |  めうめう🎒 | 
| 提出日時 | 2016-03-28 00:31:23 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,003 bytes | 
| コンパイル時間 | 738 ms | 
| コンパイル使用メモリ | 74,308 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-02 05:38:11 | 
| 合計ジャッジ時間 | 1,810 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | AC * 5 WA * 19 | 
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)
int main() {
	int g_y = 0,c_y = 0,p_y = 0,g_f = 0,c_f = 0,p_f = 0;
	string str;
	cin >> g_y >> c_y >> p_y;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] == 'G') g_f++;
		else if(str[i] == 'C') c_f++;
		else if(str[i] == 'P') p_f++;
	}
	int point = 0;
	if(g_y >= c_f) {
		point += 3 * c_f;
		g_y -= c_f;
		c_f = 0;
	}else{
		point += 3 * g_y;
		c_f -= g_y;
		g_y = 0;
	}
	if(c_y >= p_f){
		point += 3 * p_f;
		c_y -= p_f;
		p_f = 0;
	}else{
		point += 3 * c_y;
		p_f -= c_y;
		c_y = 0;
	}
	if(p_y >= g_f){
		point += 3 * g_f;
		p_y -= g_f;
		g_f = 0;
	}else{
		point += 3 * p_y;
		g_f -= p_y;
		p_y = 0;
	}
	point += min(g_f,g_y) + min(c_y,c_f) + min(p_y,p_f);
	cout << point << endl;
	return 0;
}
            
            
            
        