結果

問題 No.2495 Three Sets
ユーザー 沙耶花沙耶花
提出日時 2023-10-06 22:27:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,417 ms / 3,000 ms
コード長 1,485 bytes
コンパイル時間 4,753 ms
コンパイル使用メモリ 263,940 KB
実行使用メモリ 6,564 KB
最終ジャッジ日時 2023-10-06 22:27:57
合計ジャッジ時間 12,145 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 225 ms
4,508 KB
testcase_14 AC 653 ms
5,444 KB
testcase_15 AC 247 ms
4,768 KB
testcase_16 AC 1,399 ms
6,564 KB
testcase_17 AC 1,417 ms
6,212 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1,175 ms
6,212 KB
testcase_20 AC 1,417 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
long long A,B,C;
vector<long long> a,b,c;

long long get2(long long x,long long y,long long mid){
	
	return x * c[mid] + y * mid;
}

long long get(long long x,long long y,long long mid){
	long long l = 0,r = C;
	while(r-l>=3){
		long long m0 = l + (r-l)/3;
		long long m1 = m0 + (r-l)/3;
		if(get2(x,b[mid],m0) <= get2(x,b[mid],m1))l = m0;
		else r = m1;
		
	}
	long long ret = -Inf64;
	for(long long i=max(0LL,l-2);i<=min(C,r+2);i++)ret = max(ret,get2(x,b[mid],i));
	return ret + y * mid;
}

int main(){
	
	
	cin>>A>>B>>C;
	a.resize(A),b.resize(B),c.resize(C);
	//vector<long long> a(A),b(B),c(C);
	rep(i,a.size())cin>>a[i];
	rep(i,b.size())cin>>b[i];
	rep(i,c.size())cin>>c[i];
	sort(a.rbegin(),a.rend());
	sort(b.rbegin(),b.rend());
	sort(c.rbegin(),c.rend());
	b.insert(b.begin(),0);
	c.insert(c.begin(),0);
	rep(i,B)b[i+1] += b[i];
	rep(i,C)c[i+1] += c[i];
	long long x = 0,y = 0;
	long long ans = -Inf64;
	rep(i,A+1){
		x = i;
		
		long long l = 0,r = B;
		while(r-l>=3){
			long long m0 = l + (r-l)/3;
			long long m1 = m0 + (r-l)/3;
			if(get(x,y,m0) <= get(x,y,m1))l = m0;
			else r = m1;
			
		}
		for(long long i=max(0LL,l-2);i<=min(B,r+2);i++)ans = max(ans,get(x,y,i));
		if(i<A)y += a[i];
	}
	cout<<ans<<endl;
	return 0;
}
0