結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー HankHank
提出日時 2016-08-16 23:35:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,628 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 59,160 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 08:11:38
合計ジャッジ時間 1,816 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 WA -
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 WA -
testcase_48 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int main(){
  int flag,num=0,count=1,D;
  //std::vector<int> c[13];
  int c[13];
  char a,memo;
  int result=0;

  cin >> D;//Dの入力
  cin >> a;//初期入力を確保
  memo = a;
  (a=='o')?(flag = 1):(flag = 0);//初期入力が休日ならフラグ立つ
  for (size_t i = 1; i < 14; i++) {
    cin >> a;
    //入力した文字が前に入力した文字と一致すれば、この文字の連続回数を数える。
    if(a == memo)count = count + 1;
    else{//一致しなければ連続回数を保存
      c[num]=count;
      count = 1;
      num = num + 1;
      memo = a;
    }
  }
  c[num]=count;
  num = num+1;

  //得られた数列を操作する。
  //平日の日数がもしD以下なら、その平日の数字と自分の一個前と一個後ろの休日と和をとる
  //そうでなければ、Dはその平日の前とその平日の後ろの休日の大きい方と和をとる
  //得られた和の中、一番大きいのを選んで出力。
  if(flag == 1) result = D+c[0];
  for (size_t i = flag; i < num; i=i+2) {//全ては平日の操作になる
    if(c[i]<=D){
      count = c[i];
      (i==0)?(0):(count = count + c[i-1]);
      (i==13)?(0):(count = count + c[i+1]);
    }
    else{
      //ここでflag使わないので、変数として使わせていただきます
      (i==0)?(flag = 0):(flag = c[i-1]);
      (i==13)?(count = 0):(count = c[i+1]);
      (count > flag)?(0):(count = flag);
      count = count + D;
    }
    if(count > result) result = count;
  }
  cout << result << endl;
}
0