結果

問題 No.2495 Three Sets
ユーザー kwm_tkwm_t
提出日時 2023-10-07 10:52:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 498 ms / 3,000 ms
コード長 1,845 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 202,392 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-07 10:52:15
合計ジャッジ時間 11,196 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
4,380 KB
testcase_01 AC 268 ms
4,380 KB
testcase_02 AC 406 ms
4,376 KB
testcase_03 AC 260 ms
4,376 KB
testcase_04 AC 257 ms
4,380 KB
testcase_05 AC 253 ms
4,380 KB
testcase_06 AC 288 ms
4,380 KB
testcase_07 AC 472 ms
4,380 KB
testcase_08 AC 431 ms
4,376 KB
testcase_09 AC 261 ms
4,376 KB
testcase_10 AC 261 ms
4,380 KB
testcase_11 AC 473 ms
4,380 KB
testcase_12 AC 459 ms
4,380 KB
testcase_13 AC 498 ms
4,376 KB
testcase_14 AC 479 ms
4,376 KB
testcase_15 AC 474 ms
4,380 KB
testcase_16 AC 487 ms
4,376 KB
testcase_17 AC 488 ms
4,376 KB
testcase_18 AC 57 ms
4,380 KB
testcase_19 AC 81 ms
4,376 KB
testcase_20 AC 486 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint998244353;
//const int mod = 998244353;
//using mint = modint1000000007;
//const int mod = 1000000007;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<long long,long long>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
inline long long ceil_div(long long x, long long y) { return (x < 0) ? x / y : (x + (y - 1)) / y; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int na, nb, nc; cin >> na >> nb >> nc;
	const int MX = 3003;
	auto f = [&](const int n) {
		vector<long long>c(MX * 2 + 1);
		rep(i, n) {
			int x; cin >> x;
			c[MX + x]++;
		}
		vector<P>res(MX * 2 + 1);
		long long cnt = 0, sum = 0;
		rrep2(i, -MX, MX + 1) {
			cnt += c[i + MX];
			sum += c[i + MX] * i;
			res[i + MX] = { cnt,sum };
		}
		return res;
	};
	auto a = f(na);
	auto b = f(nb);
	auto c = f(nc);
	long long ans = 0;
	// Sb,ScをFix
	for (auto q : b)for (auto r : c) {
		if (0 == q.first) {
			long long val = max(0LL, (long long)na * r.second) + q.second * r.first;
			chmax(ans, val);
		}
		else {
			long long x = ceil_div(-r.second, q.first);
			P p = x > MX ? P(0, 0) : a[max(0LL, x + MX)];
			long long  val = p.second * q.first + p.first * r.second + q.second * r.first;
			chmax(ans, val);
		}
	}
	cout << ans << endl;
	return 0;
}
0