結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-05 23:32:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 575 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 34,688 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:24:46 |
合計ジャッジ時間 | 887 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d%d%d%s", &G, &C, &P, S); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main() {int G, C, P;char S[333];int ans = 0;int SS[3] = {0};scanf("%d%d%d%s", &G, &C, &P, S);for(int i=0,len=strlen(S); i < len; i++) {if(S[i] == 'G') {if(P > 0) {ans += 3;P--;} else {SS[0]++;}} else if(S[i] == 'C') {if(G > 0) {ans += 3;G--;} else {SS[1]++;}} else {if(C > 0) {ans += 3;C--;} else {SS[2]++;}}}printf("%d\n", ans+min(G,SS[0])+min(C,SS[1])+min(P,SS[2]));return 0;}