結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー jp_stejp_ste
提出日時 2019-08-05 05:56:48
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 1,289 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 43,008 KB
最終ジャッジ日時 2024-04-21 02:49:23
合計ジャッジ時間 4,524 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
39,680 KB
testcase_01 AC 74 ms
43,008 KB
testcase_02 AC 66 ms
39,680 KB
testcase_03 AC 63 ms
39,296 KB
testcase_04 AC 64 ms
39,296 KB
testcase_05 AC 66 ms
39,552 KB
testcase_06 AC 63 ms
39,552 KB
testcase_07 AC 66 ms
39,552 KB
testcase_08 AC 64 ms
39,552 KB
testcase_09 AC 65 ms
39,296 KB
testcase_10 AC 66 ms
39,680 KB
testcase_11 AC 66 ms
39,680 KB
testcase_12 AC 63 ms
39,296 KB
testcase_13 AC 66 ms
39,552 KB
testcase_14 AC 65 ms
39,424 KB
testcase_15 AC 65 ms
39,552 KB
testcase_16 AC 65 ms
39,424 KB
testcase_17 AC 66 ms
39,424 KB
testcase_18 AC 66 ms
39,296 KB
testcase_19 AC 65 ms
39,296 KB
testcase_20 AC 68 ms
39,424 KB
testcase_21 AC 66 ms
39,296 KB
testcase_22 AC 66 ms
39,424 KB
testcase_23 AC 65 ms
39,296 KB
testcase_24 AC 65 ms
39,424 KB
testcase_25 AC 66 ms
39,296 KB
testcase_26 AC 66 ms
39,552 KB
testcase_27 AC 65 ms
39,424 KB
testcase_28 AC 65 ms
39,424 KB
testcase_29 AC 65 ms
39,680 KB
testcase_30 AC 65 ms
39,296 KB
testcase_31 AC 66 ms
39,296 KB
testcase_32 AC 67 ms
39,296 KB
testcase_33 AC 66 ms
39,296 KB
testcase_34 AC 65 ms
39,680 KB
testcase_35 AC 64 ms
39,424 KB
testcase_36 AC 64 ms
39,296 KB
testcase_37 AC 65 ms
39,680 KB
testcase_38 AC 64 ms
39,424 KB
testcase_39 AC 68 ms
39,424 KB
testcase_40 AC 64 ms
39,552 KB
testcase_41 AC 64 ms
39,424 KB
testcase_42 AC 66 ms
39,424 KB
testcase_43 AC 65 ms
41,464 KB
testcase_44 AC 65 ms
39,424 KB
testcase_45 AC 65 ms
39,680 KB
testcase_46 AC 65 ms
39,296 KB
testcase_47 AC 65 ms
39,424 KB
testcase_48 AC 66 ms
39,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
  const data = input.split("\n");
  const d = Number(data[0]);
  const c = data[1] + data[2];
  let realD = d;
  let realC = 'x'.repeat(d) + c + 'x'.repeat(d);
  let max = 0;
  
  for(var i=0; i<c.length; i++) {
    let len = countA(c, i);
    max = Math.max(max, len);
    i = i + len;
  }
  
  for(let j=0; j<d; j++) {
    for(let i=0; i<realC.length; i++) {
      if(haveLengthX(realC, i, realD)) {
        let len = countBeforA(realC, i-1) + realD + countAfterA(realC, i+realD);
        max = Math.max(max, len);
      } 
      
    }
    realD--;
  }
  console.log(max);
}

function countA(list, start) {
  let count = 0;
  for(let i=start; i<list.length; i++) {
    if(list[i] == 'x') return count;
    count++;
  }
  return count;
}

function haveLengthX(list, start, length) {
  for(let i=start; i<start+length; i++) {
    if(list[i] == 'o') return false;
  }
  return true;
}

function countAfterA(list, start) {
  let count = 0;
  for(let i=start; i<list.length; i++) {
    if(list[i] == 'x') return count;
    count++;
  }
  return count;
}

function countBeforA(list, start) {
  let count = 0;
  for(let i=start; i>=0; i--) {
    if(list[i] == 'x') return count;
    count++;
  }
  return count;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0