結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー Bantako
提出日時 2017-08-10 20:32:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 872 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 165,644 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 12:01:01
合計ジャッジ時間 2,568 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
int rest[17];
main(){
    int N;
    char S[15],S2[8];
    scanf("%d%s%s",&N,S,S2);
    strcat(S,S2);
    int count = 0,index = 1;
    rest[1] = 100;
    char c = 'x';
    for(int i = 0;i < 14;i++){
        if(S[i] != c){
            rest[index] += count;
            count = 1;
            c = S[i];
            index++;
        }else{
            count++;
        }
    }
    rest[index] = count;
    if(index % 2){
        rest[index] += 100;
    }else{
        rest[++index] = 100;
    }
    int max = 0;
    int turn = 1;//x->1
    for(int i = 1;i <= index;i++){
        if(turn){
            if(N >= rest[i]){
                max = std::max(max,rest[i-1]+rest[i]+rest[i+1]);
            }else{
                max = std::max(max,std::max(rest[i-1]+N,rest[i+1]+N));
            }
        }
        turn = !turn;
    }
    printf("%d\n",max);
}
0