結果
| 問題 |
No.2859 Falling Balls
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2024-08-25 14:22:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,979 bytes |
| コンパイル時間 | 4,391 ms |
| コンパイル使用メモリ | 264,608 KB |
| 最終ジャッジ日時 | 2025-02-24 01:09:44 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 24 |
ソースコード
#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;
}
ll op(ll a, ll b){
return max(a, b);
}
ll e(){
return -1e18;
}
int main(){
int n; cin >> n;
ll k; cin >> k;
vector<ll> t(n), x(n), c(n);
vector<tuple<ll,ll,ll>> f(n);
rep(i,0,n) cin >> t[i];
rep(i,0,n) cin >> x[i];
rep(i,0,n) cin >> c[i];
rep(i,0,n) f[i] = make_tuple(t[i], x[i], c[i]);
sort(f.begin(), f.end());
rep(i,0,n){
t[i] = get<0>(f[i]);
x[i] = get<1>(f[i]);
c[i] = get<2>(f[i]);
}
vector<ll> dat(n);
rep(i,0,n) dat[i] = x[i] - k * t[i];
dat.push_back(0);
sort(dat.begin(), dat.end());
dat.erase(unique(dat.begin(), dat.end()), dat.end());
auto get = [&](int i) -> int {
ll g = x[i] - k * t[i];
return lower_bound(dat.begin(), dat.end(), g) - dat.begin();
};
int m = dat.size();
segtree<ll,op,e> seg(m);
seg.set(lower_bound(dat.begin(), dat.end(), 0) - dat.begin(), 0);
rep(i,0,n){
int v = get(i);
seg.set(v, max(seg.get(v), seg.prod(v, m) + c[i]));
}
cout << seg.all_prod() << '\n';
}
shobonvip