結果

問題 No.161 制限ジャンケン
ユーザー BantakoBantako
提出日時 2017-07-26 11:29:38
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 552 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 157,788 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 23:53:35
合計ジャッジ時間 3,067 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 1 ms
5,376 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d%d%d",&M[0],&M[1],&M[2]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%s",S);
      |     ~~~~~^~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int C[3];
main(){
    int M[3];
    scanf("%d%d%d",&M[0],&M[1],&M[2]);
    char S[51];
    scanf("%s",S);
    for(int i = 0;i < strlen(S);i++){
        if(S[i]=='G')C[0]++;
        else if(S[i]=='C')C[1]++;
        else C[2]++;
    }
    int point = 0,n;
    for(int i = 0;i < 3;i++){
        n = min(M[i],C[(i+1)%3]);
        M[i] -= n;C[(i+1)%3] -= n;point += n*3;
    }
    for(int i = 0;i < 3;i++){
        n = min(M[i],C[i]);
        M[i] -= n;C[i] -= n;point += n;
    }
    printf("%d\n",point);
}   
0