結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー itezpaceitezpace
提出日時 2016-07-01 08:15:53
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,666 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 61,500 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-08-03 17:03:01
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,380 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 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int d;
  cin>>d;
  char c;
  int a,b,m;
  a=0;
  b=0;
  m=0;
  vector<int> va;
  for(int i=0; i<7; ++i){
    cin>>c;
    if(c=='x'){
      b--;
      if(a!=0){
        va.push_back(a);
        a=0;
      }
    } else {
      a++;
      if(b!=0) {
        va.push_back(b);
        b=0;
      }
    }
  }
  for(int i=0; i<7; ++i){
    cin>>c;
    if(c=='x'){
      b--;
      if(a!=0){
        va.push_back(a);
        a=0;
      }
    } else {
      a++;
      if(b!=0) {
        va.push_back(b);
        b=0;
      }
    }
  }

  if(a!=0){
    va.push_back(a);
    a=0;
  } else if(b!=0) {
    va.push_back(b);
    b=0;
  }

  for(int i=0; i<va.size(); ++i){
    vector<int> vb;
    vb=va;
    int x;
    x=0;
    if(vb[i]<0){
      if(vb[i]*-1<=d){
        x=vb[i]*-1;
        if(i>0 && i<va.size()-1){
          x+=vb[i-1];
          x+=vb[i+1];
          if(x>m){
            m=x;
          }
        } else if(i==0){
          x+=vb[i+1];
          if(x>m){
            m=x;
          }
        } else{
          x+=vb[i-1];
          if(x>m){
            m=x;
          }
        }
      } else {
        x=d;
        if(i>0 && i<va.size()-1){
          if(vb[i-1]>=vb[i+1]) x+=vb[i-1];
          else x+=vb[i+1];
          if(x>m){
            m=x;
          }
        } else if(i==0){
          x+=vb[i+1];
          if(x>m){
            m=x;
          }
        } else{
          x+=vb[i-1];
          if(x>m){
            m=x;
          }
        }
      }
    }
  }
  int ml,mr;
  ml=va[0]+d;
  if(ml>m) m=ml;
  mr=va[va.size()-1]+d;
  if(mr>m) m=mr;

  cout<<m<<endl;
  return 0;
}
0