結果

問題 No.2859 Falling Balls
ユーザー t98slidert98slider
提出日時 2024-08-27 01:29:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 3,000 ms
コード長 1,096 bytes
コンパイル時間 4,962 ms
コンパイル使用メモリ 276,160 KB
実行使用メモリ 17,520 KB
最終ジャッジ日時 2024-08-27 01:29:35
合計ジャッジ時間 10,959 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 42 ms
7,040 KB
testcase_11 AC 135 ms
16,280 KB
testcase_12 AC 8 ms
6,940 KB
testcase_13 AC 126 ms
15,676 KB
testcase_14 AC 108 ms
14,656 KB
testcase_15 AC 41 ms
7,040 KB
testcase_16 AC 55 ms
8,832 KB
testcase_17 AC 53 ms
8,704 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 78 ms
10,624 KB
testcase_20 AC 150 ms
17,336 KB
testcase_21 AC 148 ms
17,448 KB
testcase_22 AC 147 ms
17,436 KB
testcase_23 AC 148 ms
17,444 KB
testcase_24 AC 147 ms
17,376 KB
testcase_25 AC 149 ms
17,432 KB
testcase_26 AC 147 ms
17,312 KB
testcase_27 AC 147 ms
17,332 KB
testcase_28 AC 149 ms
17,520 KB
testcase_29 AC 153 ms
17,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// これに似てた
// https://yukicoder.me/problems/no/1826
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

ll op(ll lhs, ll rhs){
	return max(lhs, rhs);
}
constexpr ll e(){
	return -(1ll << 62);
}

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
	for(T& x : vec) is >> x;
	return is;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll k;
	cin >> n >> k;
	vector<int> x(n), t(n), c(n);
	vector<tuple<ll,ll,int>> a(n);
	vector<ll> ca(n + 1);
	cin >> t >> x >> c;
	for(int i = 0; i < n; i++){
		a[i] = make_tuple(x[i] + k * t[i], -(x[i] - k * t[i]), c[i]);
		ca[i] = get<1>(a[i]);
	}
	sort(a.begin(), a.end());
	sort(ca.begin(), ca.end());
	ca.erase(unique(ca.begin(), ca.end()), ca.end());
	const int m = ca.size();
	atcoder::segtree<ll, op, e> seg(m);
	auto pget = [&](ll pos){ return lower_bound(ca.begin(), ca.end(), pos) - ca.begin(); };
	seg.set(pget(0), 0);
	for(auto &&[u, v, c] : a){
		if(u < 0) continue;
		int p = pget(v);
		seg.set(p, seg.prod(0, p + 1) + c);
	}
	cout << seg.all_prod() << '\n';
}
0