結果

問題 No.1765 While Shining
ユーザー monaka
提出日時 2022-01-02 03:21:02
言語 TypeScript
(5.7.2)
結果
TLE  
実行時間 -
コード長 492 bytes
コンパイル時間 8,727 ms
コンパイル使用メモリ 228,672 KB
実行使用メモリ 54,180 KB
最終ジャッジ日時 2024-12-31 16:42:22
合計ジャッジ時間 15,104 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

function main(input) {
  const n = Number(input[0]);
  const bit = input[1].split(" ");
  let ans = 0;
  for(let i=0; i<n; i++) {
    ans += move(bit, i);   
  }
  console.log(ans);
}

function move(bit, i) {
  let j = i;
  while(true) {
    let nowBit = bit[j];
    if(((j-i) % 2) === 1) {
      nowBit = nowBit === "1" ? "0" : "1";
    }
    if(nowBit === "0" || j === (bit.length-1)) break;
    j++;
  }
  return j-i;
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));
0