結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-05 23:33:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 482 ms |
コンパイル使用メモリ | 59,520 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:25:08 |
合計ジャッジ時間 | 1,128 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | while(scanf("%c",&S),S!='\n'){ | ~~~~~^~~~~~~~~
ソースコード
#include<iostream>#include<cstdio>#include<vector>#include<algorithm>using namespace std;int main(){int G,C,P,ans=0;char S;int limit[3]={},cnt[3]={};for(int i=0;i<3;i++) cin>>limit[i];cin.ignore();while(scanf("%c",&S),S!='\n'){if(S=='G') cnt[0]++;else if(S=='C') cnt[1]++;else if(S=='P') cnt[2]++;}for(int i=0;i<3;i++){int win = min(limit[i],cnt[(i+1)%3]);ans += win*3;limit[i] -= win; cnt[(i+1)%3] -= win;}for(int i=0;i<3;i++){if(limit[i]>0) ans += min(cnt[i],limit[i]);}printf("%d\n",ans);return 0;}