結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー jp_stejp_ste
提出日時 2020-05-03 22:14:26
言語 JavaScript
(node v21.7.1)
結果
TLE  
実行時間 -
コード長 2,794 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 52,944 KB
最終ジャッジ日時 2024-04-21 03:25:42
合計ジャッジ時間 16,144 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
52,944 KB
testcase_01 AC 642 ms
45,632 KB
testcase_02 AC 128 ms
45,692 KB
testcase_03 AC 689 ms
45,816 KB
testcase_04 AC 731 ms
45,880 KB
testcase_05 AC 171 ms
45,624 KB
testcase_06 AC 961 ms
45,756 KB
testcase_07 AC 918 ms
45,652 KB
testcase_08 AC 1,752 ms
45,928 KB
testcase_09 AC 1,183 ms
45,732 KB
testcase_10 AC 1,396 ms
46,208 KB
testcase_11 TLE -
testcase_12 AC 71 ms
39,424 KB
testcase_13 AC 67 ms
39,424 KB
testcase_14 AC 66 ms
39,680 KB
testcase_15 AC 66 ms
39,552 KB
testcase_16 AC 66 ms
39,552 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

function main(input) {
  let [N] = getIntegers(input);
  let S = input.shift();
  let A = getIntegers(input);
  let [Q] = getIntegers(input);
  let K = getIntegers(input);
  
  let dp = [A[0]];
  for(let i=1; i<N; i++) {
    dp[i] = dp[i-1] + A[i];
  }
  
  for(let i=0; i<Q; i++) {
    let max = 0;
    let v = 0;
    for(let j=0; j<S.length; j++) {
      let NS = S.substr(j);
      if(j>0) {
        v += A[j-1];
      }
      if(NS[0] == 'W') continue;
      let tmp = NS.substr(0, binary(NS,K[i],dp, j, v)).split("E").length-1;
      max = Math.max(max, tmp);
    }
    console.log(max);
  }
}

function binary(S,K,DP,j,v) {
  let l = 0;
  let r = S.length;
  let count = 64;
  while(count-- > 0) {
    let X = Math.floor((l + r) / 2);
    if(K >= DP[X+j]-v) {
      l = X;
    } else {
      r = X;
    }
  }
  return r;
}

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

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

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

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

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].oneLineString());
    } 
  } else {
    outList.push(this.oneLineString());
  }
  console.log(outList.join("\n") + "\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;
  });
};

Array.prototype.oneLineString = function() {
  let str = "";
  this.forEach(function(e, i) {
    if(i > 0) str += " ";
    str += e;
  });
  return str;
};

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