結果

問題 No.3424 Shooting Game
コンテスト
ユーザー anago-pie
提出日時 2026-01-26 16:29:20
言語 JavaScript
(node v25.2.1)
結果
AC  
実行時間 1,310 ms / 2,000 ms
コード長 1,400 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 133 ms
コンパイル使用メモリ 7,844 KB
実行使用メモリ 118,440 KB
最終ジャッジ日時 2026-01-26 16:29:39
合計ジャッジ時間 16,610 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

function Main(INPUT){
  const input=INPUT.split("\n");
  const [N,T]=input[0].split(" ").map(_=>parseInt(_));

  class SegTree{
    tree=[];
    n=1;
    constructor(N){
      while(this.n<N){
        this.n*=2;
      }
      this.tree=initArray(this.n*2, 0);
    }

    update(x,l,r,b,u,now){
      if(l>=u || r<=b){
        return;
      }
      else if(l<=b && r>=u){
        this.tree[now]=Math.max(this.tree[now], x);
      }
      else{
        this.update(x,l,r,b,Math.floor((b+u)/2), now*2+1);
        this.update(x,l,r,Math.floor((b+u)/2),u,now*2+2);
      }
    }

    query(x,l,r){
      this.update(x,l,r,0,this.n,0);
    }

    get(i){
      let now=this.n-1+i;
      let ret=this.tree[now];
      while(now>0){
        now=Math.floor((now-1)/2);
        ret=Math.max(ret, this.tree[now]);
      }
      return ret;
    }
  }

  const st = new SegTree(200005);
  for(let i=0;i<N;i++){
    const [L,R,P]=input[1+i].split(" ").map(_=>parseInt(_));
    st.query(P,L,R+1);
  }
  const dp=initArray(200003, 0);
  for(let i=0;i<200001;i++){
    dp[i+1]=Math.max(dp[i+1], dp[i]);
    dp[Math.min(i+T, 200001)]=Math.max(dp[Math.min(i+T, 200001)], dp[i]+st.get(i));
  }
  console.log(dp[200001]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



function initArray(numberOfItems, initiationOfItem){
  return new Array(numberOfItems).fill().map(_=>structuredClone(initiationOfItem));
}
0