結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-06-13 13:31:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 678 bytes |
| コンパイル時間 | 635 ms |
| コンパイル使用メモリ | 74,840 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 16:06:22 |
| 合計ジャッジ時間 | 1,424 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:17: warning: ‘op’ may be used uninitialized in this function [-Wmaybe-uninitialized]
14 | int og, oc, op;
| ^~
main.cpp:14:13: warning: ‘oc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
14 | int og, oc, op;
| ^~
main.cpp:14:9: warning: ‘og’ may be used uninitialized in this function [-Wmaybe-uninitialized]
14 | int og, oc, op;
| ^~
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;
int main(){
int G, C, P;
cin >> G >> C >> P;
int og, oc, op;
string S;
cin >> S;
for(int i = 0; i < S.size(); i++){
if(S[i] == 'G') og++;
if(S[i] == 'C') oc++;
if(S[i] == 'P') op++;
}
LL ans = 0;
ans += min(G, oc) * 3;
G -= min(G, oc);
ans += min(C, op) * 3;
C -= min(C, op);
ans += min(P, og) * 3;
P -= min(P, og);
ans += min(G, og);
ans += min(C, oc);
ans += min(P, op);
cout << ans << endl;
return 0;
}
machy