結果
| 問題 |
No.2961 Shiny Monster Master
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-19 01:37:47 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
AC
|
| 実行時間 | 298 ms / 1,777 ms |
| コード長 | 826 bytes |
| コンパイル時間 | 45 ms |
| コンパイル使用メモリ | 6,688 KB |
| 実行使用メモリ | 55,992 KB |
| 最終ジャッジ日時 | 2024-11-19 01:38:08 |
| 合計ジャッジ時間 | 15,733 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 77 |
ソースコード
function Main(INPUT){
const input=INPUT.split("\n");
const [R,N] = input[0].split(" ").map(_=>parseInt(_));
let count = input[1].split(" ").map(_=>parseInt(_));
count = count.sort((a,b)=>a-b);
const Q=parseInt(input[2]);
for(let i=0;i<Q;i++){
let [l,r]=input[3+i].split(" ").map(_=>parseInt(_));
l--;
let [cl,cr]=[l%R, r%R];
let[lok,lng,rok,rng]=[-1,N,-1,N];
while(lng>lok+1){
let mid = Math.floor((lng+lok)/2);
if(count[mid]<=cl){
lok=mid;
}
else{
lng=mid;
}
}
while(rng>rok+1){
let mid = Math.floor((rng+rok)/2);
if(count[mid]<=cr){
rok=mid;
}
else{
rng=mid;
}
}
console.log(N*Math.floor(r/R)+rng - N*Math.floor(l/R)-lng);
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));