結果
| 問題 | No.3424 Shooting Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-20 14:21:25 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,720 bytes |
| 記録 | |
| コンパイル時間 | 5,972 ms |
| コンパイル使用メモリ | 218,864 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-01-20 14:21:38 |
| 合計ジャッジ時間 | 5,206 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using SS = int;
class DualSegmentTree{
//作用させるものの交換法則が成り立つ時&&lazy->lazyとlazy->datの作用が同じ時専用.
//出来ないときは遅延セグ木 出来たとしても改良必須あり.
int siz,n;
vector<SS> dat;
void mapping(SS f,SS &x){x = min(x,f);}
//FF composition(FF f, FF g){mappingと同じ?} チェック.
SS e(){return 1001001001;}
public:
DualSegmentTree(int N):n(N){
n = N,siz = 1;
while(siz < n) siz += siz;
dat.resize(siz*2,e());
}
DualSegmentTree(vector<SS> &A){
n = A.size(),siz = 1;
while(siz < n) siz += siz;
dat.resize(siz*2,e());
for(int i=0; i<n; i++) dat.at(i+siz) = A.at(i);
}
void update(int pos,SS x){
pos += siz;
mapping(x,dat.at(pos));
}
void update(int l,int r,SS x){
l += siz,r += siz;
while(l < r){
if(l&1) mapping(x,dat.at(l)),l++;
if(r&1) r--,mapping(x,dat.at(r));
l >>= 1; r >>= 1;
}
}
SS get(int pos){
pos = pos+siz;
SS ret = dat.at(pos);
while(pos != 1) pos = pos>>=1,mapping(dat.at(pos),ret);
return ret;
}
};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,T; cin >> N >> T;
int n = 200001;
vector<long long> dp(n+1);
DualSegmentTree Z(n);
while(N--){
int l,r,p; cin >> l >> r >> p;
Z.update(l,r+1,p);
}
for(int i=0; i<n; i++){
dp.at(i+1) = max(dp.at(i),dp.at(i+1));
dp.at(min(n,i+T)) = max(dp.at(min(n,i+T)),dp.at(i)+Z.get(i));
}
cout << dp.at(n) << endl;
}