結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー jp_stejp_ste
提出日時 2020-05-04 22:07:02
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 2,396 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 46,080 KB
最終ジャッジ日時 2024-04-21 03:26:34
合計ジャッジ時間 11,174 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
45,480 KB
testcase_01 AC 153 ms
45,824 KB
testcase_02 AC 76 ms
43,264 KB
testcase_03 AC 141 ms
44,752 KB
testcase_04 AC 148 ms
45,312 KB
testcase_05 AC 82 ms
43,264 KB
testcase_06 AC 202 ms
45,684 KB
testcase_07 AC 186 ms
45,492 KB
testcase_08 AC 294 ms
45,952 KB
testcase_09 AC 219 ms
45,260 KB
testcase_10 AC 248 ms
45,824 KB
testcase_11 AC 267 ms
45,696 KB
testcase_12 AC 65 ms
39,168 KB
testcase_13 AC 61 ms
39,424 KB
testcase_14 AC 63 ms
39,168 KB
testcase_15 AC 65 ms
39,040 KB
testcase_16 AC 64 ms
39,168 KB
testcase_17 AC 269 ms
45,952 KB
testcase_18 AC 125 ms
44,060 KB
testcase_19 AC 233 ms
45,448 KB
testcase_20 AC 169 ms
44,600 KB
testcase_21 AC 101 ms
44,220 KB
testcase_22 AC 76 ms
43,264 KB
testcase_23 AC 73 ms
39,680 KB
testcase_24 AC 76 ms
43,264 KB
testcase_25 AC 76 ms
43,264 KB
testcase_26 AC 66 ms
39,296 KB
testcase_27 AC 64 ms
39,296 KB
testcase_28 AC 78 ms
43,392 KB
testcase_29 AC 80 ms
43,264 KB
testcase_30 AC 76 ms
43,520 KB
testcase_31 AC 76 ms
43,264 KB
testcase_32 AC 77 ms
43,264 KB
testcase_33 AC 181 ms
44,736 KB
testcase_34 AC 278 ms
45,824 KB
testcase_35 AC 255 ms
46,080 KB
testcase_36 AC 116 ms
43,960 KB
testcase_37 AC 179 ms
45,112 KB
testcase_38 AC 197 ms
45,420 KB
testcase_39 AC 283 ms
45,952 KB
testcase_40 AC 304 ms
45,824 KB
testcase_41 AC 309 ms
45,824 KB
testcase_42 AC 254 ms
45,696 KB
testcase_43 AC 300 ms
45,952 KB
testcase_44 AC 182 ms
45,432 KB
testcase_45 AC 292 ms
45,696 KB
testcase_46 AC 121 ms
45,260 KB
testcase_47 AC 184 ms
45,416 KB
testcase_48 AC 140 ms
44,324 KB
testcase_49 AC 171 ms
45,280 KB
testcase_50 AC 173 ms
44,976 KB
testcase_51 AC 202 ms
45,368 KB
testcase_52 AC 196 ms
45,504 KB
testcase_53 AC 266 ms
45,824 KB
testcase_54 AC 119 ms
44,176 KB
testcase_55 AC 86 ms
43,688 KB
testcase_56 AC 232 ms
45,260 KB
testcase_57 AC 185 ms
45,356 KB
testcase_58 AC 68 ms
39,168 KB
testcase_59 AC 63 ms
39,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function main(input) {
  let [N] = getIntegers(input);
  let S = getStrings(input, "");
  let A = getIntegers(input);
  let [Q] = getIntegers(input);
  let K = getIntegers(input);

  for(let i=0; i<Q; i++) {
    let max = 0;
    let sum = 0;
    let count = 0;
    let right = 0;
    for(let left=0; left<N; left++) {
      while(sum + A[right] <= K[i] && right < N) {
        if(S[right] == 'E') count++;
        sum += A[right];
        right++;
      }
      max = Math.max(max, count);
      if(S[left] == 'E') count--;
      sum -= A[left];
    }
    console.log(max);
  }
}

//-- functions ------------------------------------

function getIntegers(lines, sep=" ") {
  return lines.shift().split(sep).map(function(e) {
    return Number(e);
  });
}

function getBigIntegers(lines, sep=" ") {
  return lines.shift().split(sep).map(function(e) {
    return BigInt(e);
  });
}

function getStrings(lines, sep=" ") {
  return lines.shift().split(sep);
}

function twoDimenArrayByValue(h, w, value) {
  const list = new Array(h);
  for(let i=0; i<h; i++) {
    list[i] = new Array(w).fill().map(function(e) {
      return value.constructor == Array ? Array.from(value) : value;
    });
  }
  return list;
}

function twoDimenArrayByStrings(h, strings) {
  const list = new Array(h);
  for(let i=0; i<h; i++) {
    list[i] = strings.shift().split("");
  }
  return list;
}

function distance(x1, y1, x2, y2) {
  return Math.sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));
}

function gcd(a, b) {
  return b === 0 ? a : gcd(b, a % b);
}

//-- Array -------------------------------------------

Array.prototype.deepCopy = function(list) {
  let retList = [];
  for(let i=0; i<list.length; i++) {
    retList[i] = list[i].constructor == Array ? Array.from(list[i]) : list[i];
  }
  return retList;
};

Array.prototype.out = function() {
  let outList = [];
  if(this[0].constructor == Array) {
    for(let i=0; i<this.length; i++) {
      outList.push(this[i].join(" "));
    } 
  } else {
    outList.push(this.join(" "));
  }
  console.log(outList.join("\n"));
};

Array.prototype.pushNoSameValue = function(...values) {
  values.forEach(function(e) {
    if(!this.includes(e)) {
      this.push(e);
    }
  }, this);
};

Array.prototype.sortByIntegers = function() {
  this.sort(function(a, b) {
    return a - b;
  });
};

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