結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-05-25 01:45:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 568 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 23,424 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:36:27 |
合計ジャッジ時間 | 847 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d %d %d",&G,&C,&P); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%s",S); | ~~~~~^~~~~~~~
ソースコード
#include<stdio.h>int min(int a,int b){if(a<b){return a;}else{return b;}}int main(void){int G,C,P;char S[301];int i,G2,C2,P2,ans;scanf("%d %d %d",&G,&C,&P);scanf("%s",S);G2=0;C2=0;P2=0;for(i=0;i<G+C+P;i++){if(S[i]=='G'){G2++;}if(S[i]=='C'){C2++;}if(S[i]=='P'){P2++;}}ans = 0;i = min(G,C2);ans = ans + i*3;G = G - i;C2 = C2 - i;i = min(C,P2);ans = ans + i*3;C = C - i;P2 = P2 - i;i = min(P,G2);ans = ans + i*3;P = P - i;G2 = G2 - i;ans = ans + min(P,P2) + min(G,G2) + min(C,C2);printf("%d\n",ans);}