結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
kaito_tateyama
|
| 提出日時 | 2019-03-10 20:46:02 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 526 bytes |
| コンパイル時間 | 49 ms |
| コンパイル使用メモリ | 6,692 KB |
| 実行使用メモリ | 55,360 KB |
| 最終ジャッジ日時 | 2024-10-13 01:01:24 |
| 合計ジャッジ時間 | 6,503 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 2 |
| other | -- * 22 |
ソースコード
const input = require('fs').readFileSync('/dev/stdin', 'utf8').slice(0,-1);
const [N, X, ...a] = input.split(/\s/);
const isOK = (index, key) => a[index] >= key;
const binary_search = key => {
let ng = -1;
const ok = a.length;
while (Math.abs(ok - ng) > 1) {
mid = ng + (ok - ng) / 2;
mid |=0;
if (isOK(mid, key)) OK = mid;
else ng = mid;
}
return ok;
};
let sum = 0;
a.sort((a, b) => a - b);
for (const xx of a) {
sum += binary_search(X - xx + 1) - binary_search(X - xx);
}
console.log(sum);
kaito_tateyama