結果

問題 No.3424 Shooting Game
コンテスト
ユーザー MM
提出日時 2026-01-11 15:49:11
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 1,556 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,717 ms
コンパイル使用メモリ 279,464 KB
実行使用メモリ 17,240 KB
最終ジャッジ日時 2026-01-11 15:49:19
合計ジャッジ時間 7,753 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec vector
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back 
#define eb emplace_back

using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
const ll mod = 998244353;
using mint = modint998244353;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};
using Graph = vector<vector<pair<int,ll>>>;
// using Graph = vector<vector<int>>;

// https://betrue12.hateblo.jp/entry/2020/09/23/005940
using S = long long;
using F = long long;
const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b){ return std::max(a, b); }
S e(){ return -INF; }
S mapping(F f, S x){ return (f == ID ? x : f); }
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

int main(){
  // input
  int N, T;
  cin >> N >> T;

  const int M = 200010;
  vector<S> v(M,0LL);
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
  // Graph G(M);
  // rep(i,M-1) G[i].eb(i+1,0LL);
  

  vector<ll> L(N),R(N),P(N);
  rep(i,N){
    cin >> L[i] >> R[i] >> P[i];
    ++R[i];
    seg.apply(L[i],R[i],(ll)P[i]);
    // pq.push({P[i],L[i],R[i]});
  }
  
  // solve
  vector<ll> dp(M+1,0LL);
  ll now = 0;
  rep(i,M){
    chmax(dp[i],now);
    ll x = seg.prod(i,i+1), y = min(M,i+T);
    
    chmax(dp[y],dp[i]+x);
    
    chmax(now,dp[i]);
    chmax(dp[i+1],dp[i]);
  }
  
  // output
  cout << dp[M] << endl;
}
0