結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-05 23:33:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 51,092 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 04:24:52 |
合計ジャッジ時間 | 1,021 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | int g,c,p;char s[501];scanf("%d%d%d%s",&g,&c,&p,s); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <map> #include <vector> #include <algorithm> using namespace std; //namaega184 int main(){ int g,c,p;char s[501];scanf("%d%d%d%s",&g,&c,&p,s); int gg=0,cc=0,pp=0; int len=strlen(s); int ans=0; for(int i=0;i<len;i++){ if(s[i]=='G')gg++; else if(s[i]=='C')cc++; else pp++; } int tmp=min(p,gg); ans+=tmp*3; p-=tmp,gg-=tmp; tmp=min(g,cc); ans+=tmp*3; g-=tmp,cc-=tmp; tmp=min(c,pp); ans+=tmp*3; c-=tmp,pp-=tmp; printf("%d\n",ans+min(g,gg)+min(p,pp)+min(c,cc)); return 0; }