結果
| 問題 |
No.2808 Concentration
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2024-07-12 22:55:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 359 ms / 2,000 ms |
| コード長 | 2,197 bytes |
| コンパイル時間 | 4,393 ms |
| コンパイル使用メモリ | 255,228 KB |
| 最終ジャッジ日時 | 2025-02-22 04:58:25 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 57 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
// defcomp
template <typename T>
vector<T> compress(vector<T> &X) {
vector<T> vals = X;
sort(vals.begin(), vals.end());
vals.erase(unique(vals.begin(), vals.end()), vals.end());
return vals;
}
// -----
// importbisect
template <typename T>
int bisect_left(vector<T> &X, T v){
return lower_bound(X.begin(), X.end(), v) - X.begin();
}
template <typename T>
int bisect_right(vector<T> &X, T v){
return upper_bound(X.begin(), X.end(), v) - X.begin();
}
// -----
ll op(ll a, ll b){
return max(a, b);
}
ll e(){
return -1e18;
}
int main(){
int n; cin >> n;
ll s, h; cin >> s >> h;
vector<ll> x(n), y(n), z(n);
rep(i,0,n){
cin >> x[i] >> y[i] >> z[i];
}
vector<ll> dp(2*(n+1));
segtree<ll,op,e> seg(n+1);
vector<ll> rui(n+1);
rep(i,0,n){
rui[i+1] = rui[i] + z[i];
}
seg.set(0, 0);
rep(i,1,n+1){
chmax(dp[i], dp[i-1]);
chmax(dp[n+1+i], dp[n+i]);
int r = bisect_right(y, x[i-1]-h);
if (r >= 0){
chmax(dp[i-1], dp[n+1+r]);
}
seg.set(i-1, dp[i-1]-rui[i-1]);
r = bisect_left(x, y[i-1]-s);
chmax(dp[i+n+1], seg.prod(r, i) + rui[i]);
//cout << r << ' ' << i << ' ' << dp[i] << endl;
}
cout << max(dp) << endl;
}
shobonvip