結果
問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
ユーザー | jp_ste |
提出日時 | 2020-05-04 02:24:41 |
言語 | JavaScript (node v21.7.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,898 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 5,376 KB |
実行使用メモリ | 45,848 KB |
最終ジャッジ日時 | 2024-04-21 03:26:16 |
合計ジャッジ時間 | 16,689 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 285 ms
44,752 KB |
testcase_07 | WA | - |
testcase_08 | AC | 565 ms
45,188 KB |
testcase_09 | AC | 408 ms
45,084 KB |
testcase_10 | AC | 462 ms
45,184 KB |
testcase_11 | WA | - |
testcase_12 | AC | 57 ms
38,656 KB |
testcase_13 | AC | 59 ms
38,784 KB |
testcase_14 | AC | 58 ms
38,528 KB |
testcase_15 | WA | - |
testcase_16 | AC | 56 ms
38,912 KB |
testcase_17 | AC | 1,004 ms
43,276 KB |
testcase_18 | AC | 184 ms
44,940 KB |
testcase_19 | AC | 378 ms
44,764 KB |
testcase_20 | AC | 292 ms
44,960 KB |
testcase_21 | AC | 99 ms
45,056 KB |
testcase_22 | AC | 78 ms
44,604 KB |
testcase_23 | WA | - |
testcase_24 | AC | 68 ms
42,368 KB |
testcase_25 | AC | 65 ms
42,368 KB |
testcase_26 | AC | 62 ms
42,368 KB |
testcase_27 | AC | 61 ms
38,656 KB |
testcase_28 | WA | - |
testcase_29 | AC | 72 ms
42,840 KB |
testcase_30 | AC | 65 ms
42,368 KB |
testcase_31 | WA | - |
testcase_32 | AC | 71 ms
42,984 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 154 ms
45,120 KB |
testcase_37 | WA | - |
testcase_38 | AC | 293 ms
45,012 KB |
testcase_39 | WA | - |
testcase_40 | AC | 534 ms
45,188 KB |
testcase_41 | WA | - |
testcase_42 | AC | 432 ms
45,220 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 206 ms
44,952 KB |
testcase_49 | WA | - |
testcase_50 | AC | 280 ms
44,952 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | AC | 484 ms
45,184 KB |
testcase_54 | AC | 155 ms
44,932 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 60 ms
38,912 KB |
testcase_59 | AC | 58 ms
38,912 KB |
ソースコード
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]; } let dp2 = [(S[0] == 'E' ? 1:0)]; for(let i=1; i<N; i++) { dp2[i] = dp2[i-1] + (S[i] == 'E' ? 1:0); } let list = []; for(let i=0; i<Q; i++) { let max = 0; let v = 0; for(let j=0; j<S.length; j++) { if(j>0) { v += A[j-1]; } if(S[j] == 'W') continue; let tmp = dp2[j+binary(S,K[i],dp, j, v)] - (j>0 ? dp2[j-1] : 0); max = Math.max(max, tmp); } list.push(max); } console.log(list.join("\n")); } function binary(S,K,DP,j,v) { let l = 0; let r = S.length; while(r - l > 1) { let X = Math.floor((l + r) / 2); if(K >= DP[X+j]-v) { l = X; } else { r = X; } } return l; } //-- 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"));