結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2016-04-16 15:53:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 753 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 55,540 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:52:23 |
合計ジャッジ時間 | 986 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include<iostream> #include<string> using namespace std; int main(){ int G,C,P; string S; int Ge=0,Ce=0,Pe=0; int ans=0; cin>>G>>C>>P; cin>>S; for(int i=0;i<S.size();i++){ if(S[i]=='C') Ce++; else if(S[i]=='G') Ge++; else Pe++; } if(G>Ce){ G-=Ce; ans+=Ce*3; Ce=0; } else{ Ce-=G; ans+=G*3; G=0; } if(C>Pe){ C-=Pe; ans+=Pe*3; Pe=0; } else{ Pe-=C; ans+=C*3; C=0; } if(P>Ge){ P-=Ge; ans+=Ge*3; Ge=0; } else{ Ge-=P; ans+=P*3; P=0; } if(G>Ge){ G-=Ge; ans+=Ge; Ge=0; } else{ Ge-=G; ans+=G; G=0; } if(C>Ce){ C-=Ce; ans+=Ce; Ce=0; } else{ Ce-=C; ans+=C; C=0; } if(P>Pe){ P-=Pe; ans+=Pe; Pe=0; } else{ Pe-=P; ans+=P; P=0; } cout<<ans<<endl; }