function main(input) { let [N, K] = getIntegers(input, " "); let A = getIntegers(input, " "); A.sortByIntegers(); let count = 0; for(let i=0; i 1) { let x = Math.floor((r + l) / 2); if(L[x] >= K) { r = x; } else { l = x; } } return r; } function upper(L, K, l=0, r=L.length) { l--; while(r - l > 1) { let x = Math.floor((r + l) / 2); if(L[x] > K) { r = x; } else { l = x; } } return r; } function getIntegers(lines, sep) { if(sep === undefined) { return lines.map(function(e) { return Number(e); }); } else { return lines.shift().split(sep).map(function(e) { if(e == '+' || e == '*') return 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 { first -= 1; // 一番端の位置からさらにずらす while (last - first > 1) { const mid = first + Math.floor((last - first) / 2); if (arr[mid] < val) first = mid; else last = mid; } return last; } const upper_bound = (arr, val, first = 0, last = arr.length) => { first -= 1; while (last - first > 1) { const mid = first - Math.floor((last - first) / 2); if (arr[mid] <= val) // ココを直すだけ first = mid; else last = mid; } return last; } //-- Array ------------------------------------------- Array.prototype.deepCopy = function(list) { let retList = []; for(let i=0; i