結果

問題 No.2495 Three Sets
ユーザー AerenAeren
提出日時 2023-10-06 21:56:21
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 3,000 ms
コード長 1,794 bytes
コンパイル時間 4,019 ms
コンパイル使用メモリ 272,012 KB
実行使用メモリ 4,684 KB
最終ジャッジ日時 2023-10-06 21:56:27
合計ジャッジ時間 5,040 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 19 ms
4,380 KB
testcase_14 AC 36 ms
4,376 KB
testcase_15 AC 23 ms
4,376 KB
testcase_16 AC 50 ms
4,632 KB
testcase_17 AC 50 ms
4,560 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 34 ms
4,616 KB
testcase_20 AC 31 ms
4,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
using namespace numbers;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	array<int, 3> n;
	cin >> n[0] >> n[1] >> n[2];
	array<vector<int>, 3> a;
	for(auto i = 0; i < 3; ++ i){
		a[i].resize(n[i]);
		copy_n(istream_iterator<int>(cin), n[i], a[i].begin());
		ranges::sort(a[i] | ranges::views::reverse);
		a[i].insert(a[i].begin(), 0);
		for(auto j = 0; j < n[i]; ++ j){
			a[i][j + 1] += a[i][j];
		}
	}
	auto eval = [&](int p0, int p1, int p2)->long long{
		return 1LL * a[0][p0] * p1 + 1LL * a[1][p1] * p2 + 1LL * a[2][p2] * p0;
	};
	auto get2 = [&](int p0, int p1)->int{
		return *ranges::partition_point(ranges::iota_view(0, n[2]), [&](int p2){ return eval(p0, p1, p2) < eval(p0, p1, p2 + 1); });
	};
	auto get1 = [&](int p0)->int{
		return *ranges::partition_point(ranges::iota_view(0, n[1]), [&](int p1){ return eval(p0, p1, get2(p0, p1)) < eval(p0, p1 + 1, get2(p0, p1 + 1)); });
	};
	auto get0 = [&]()->int{
		return *ranges::partition_point(ranges::iota_view(0, n[0]), [&](int p0){
			int p10 = get1(p0), p11 = get1(p0 + 1);
			return eval(p0, p10, get2(p0, p10)) < eval(p0 + 1, p11, get2(p0 + 1, p11));
		});
	};
	int p0 = get0(), p1 = get1(p0), p2 = get2(p0, p1);
	cout << eval(p0, p1, p2) << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////
0