結果

問題 No.2859 Falling Balls
ユーザー 沙耶花沙耶花
提出日時 2024-08-25 15:30:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,760 bytes
コンパイル時間 4,450 ms
コンパイル使用メモリ 277,044 KB
実行使用メモリ 57,136 KB
最終ジャッジ日時 2024-08-25 15:31:03
合計ジャッジ時間 20,842 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
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 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 252 ms
17,432 KB
testcase_11 AC 923 ms
52,200 KB
testcase_12 AC 39 ms
6,940 KB
testcase_13 AC 845 ms
49,896 KB
testcase_14 AC 733 ms
45,944 KB
testcase_15 AC 236 ms
16,992 KB
testcase_16 AC 337 ms
25,080 KB
testcase_17 AC 364 ms
24,472 KB
testcase_18 AC 30 ms
6,940 KB
testcase_19 AC 514 ms
30,584 KB
testcase_20 AC 1,033 ms
55,692 KB
testcase_21 AC 1,022 ms
55,876 KB
testcase_22 AC 1,035 ms
55,648 KB
testcase_23 AC 1,002 ms
57,136 KB
testcase_24 AC 1,010 ms
55,652 KB
testcase_25 AC 1,054 ms
55,612 KB
testcase_26 AC 1,041 ms
56,296 KB
testcase_27 AC 1,033 ms
56,076 KB
testcase_28 AC 1,052 ms
55,688 KB
testcase_29 AC 1,040 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

long long op(long long a,long long b){
	return max(a,b);
}

long long e(){
	return -Inf64;
}

vector<array<long long,4>> v;
vector<long long> dp;

void dfs(int l,int r){
	if(r-l<=1)return;
	int m = (l+r)/2;
	dfs(l,m);
	
	vector<long long> t0,t1;
	for(int i=l;i<r;i++){
		t0.push_back(v[i][1]);
		t1.push_back(v[i][2]);
	}
	sort(t0.begin(),t0.end());
	sort(t1.begin(),t1.end());
	
	vector<vector<int>> qs(t0.size());
	for(int i=l;i<r;i++){
		int d = distance(t0.begin(),lower_bound(t0.begin(),t0.end(),v[i][1]));
		qs[d].push_back(i);
	}
	
	segtree<long long,op,e> seg(t1.size());
	rep(i,t0.size()){
		rep(j,qs[i].size()){
			int ii = qs[i][j];
			int d = distance(t1.begin(),lower_bound(t1.begin(),t1.end(),v[ii][2]));
			if(ii<m){
				seg.set(d,max(seg.get(d),dp[ii]));
			}
			else{
				if(seg.prod(0,d+1)!=-Inf64){
					dp[ii] = max(dp[ii],seg.prod(0,d+1) + v[ii][3]);
				}
			}
		}
	}
	
	
	dfs(m,r);
}

int main() {
	
	int n;
	long long tK;
	cin>>n>>tK;
	vector<long long> t(n),x(n),y(n),a(n);
	{
		vector<long long> T(n),X(n),C(n);
		rep(i,n)cin>>T[i];
		rep(i,n)cin>>X[i];
		rep(i,n)cin>>C[i];
		rep(i,n){
			t[i] = T[i] * tK;
			x[i] = X[i];
			a[i] = C[i];
			y[i] = 0;
		}
	}
	rep(i,n){
		array<long long,4> A = {y[i],t[i]-y[i]+x[i],t[i]-y[i]-x[i],a[i]};
		v.push_back(A);
	}
	array<long long,4> A = {0,0,0,0};
	v.push_back(A);
	sort(v.begin(),v.end());
	n++;
	dp.assign(n,-Inf64);
	dp[0] = 0;
	dfs(0,n);
	
	long long ans = -Inf64;
	rep(i,n)ans = max(ans,dp[i]);
	
	cout<<ans<<endl;
	
    return 0;
}
0