結果

問題 No.2495 Three Sets
ユーザー idat_50meidat_50me
提出日時 2023-10-06 22:43:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 8,000 bytes
コンパイル時間 2,487 ms
コンパイル使用メモリ 214,700 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-07-26 16:45:51
合計ジャッジ時間 7,686 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 3 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// -------------------- main code begins at #263 -------------------- //

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

template<typename T, typename U> using vp = vector<pair<T, U>>;
template<typename T> using pque = priority_queue<T>;
template<typename T> using lpque = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename U> using umap = unordered_map<T, U>;
template<typename T> using uset = unordered_set<T>;
#define pque_op(T, op) (priority_queue<T, vector<T>, decltype(op)>(op))
#define set_op(T, op, ...) (set<T, decltype(op)>(__VA_OPT__(__VA_ARGS__, ) op))

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pil = pair<int, lint>;
using pli = pair<lint, int>;
using vint = vector<int>;
using vlint = vector<lint>;
using vpint = vector<pint>;
using vplint = vector<plint>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vbl = vector<bool>;
using qint = queue<int>;
using qlint = queue<lint>;

constexpr double PI = 3.141592653589793;
constexpr int INTINF = (1 << 30) - 1;
constexpr lint LLINF = (1LL << 62) - 1;
constexpr int MPRIME = 1000000007;
constexpr int MPRIME9 = 998244353;
constexpr lint MMPRIME = (1LL << 61) - 1;
constexpr char newl = '\n';

#define len length()
#define empb(...) emplace_back(__VA_ARGS__)
#define fi first
#define se second

#define get_rep(_1, _2, _3, func, ...) func
#define rep(i, ...) get_rep(__VA_ARGS__, rep3, rep2, rep1)(i, __VA_ARGS__)
#define rep1(i, N) for(int i = 0; i < (N); i++)
#define rep2(i, s, t) for(int i = (s); i < (t); i++)
#define rep3(i, s, t, a) for(int i = (s); i < (t); i += (a))
#define get_rrep(_1, _2, _3, func, ...) func
#define rrep(i, ...) get_rrep(__VA_ARGS__, rrep3, rrep2, rrep1)(i, __VA_ARGS__)
#define rrep1(i, N) for(int i = (N); i >= 0; i--)
#define rrep2(i, s, t) for(int i = (s); i >= (t); i--)
#define rrep3(i, s, t, a) for(int i = (s); i >= (t); i -= (a))
#define forbit(bit, k) for(int bit = 0; bit < (1 << (k)); bit++)
#define forsubset(bit, orig_bit)                                                                        \
	for(int bit = (orig_bit), _cnt = 0; (_cnt += (bit == (orig_bit))) < 2; --bit &= (orig_bit))
#define bitpop(bit, k) (((bit) >> (k)) & 1)

#define all(name) name.begin(), name.end()
#define rall(name) name.rbegin(), name.rend()
#define gsort(vbeg, vend) sort(vbeg, vend, greater<>())

#define dbg(x) cerr << #x << ": " << x << '\n';

inline int popcnt(lint bit) {
	return __builtin_popcountll(bit);
}

template<class T> inline bool chmin(T &a, T b) {
	if(a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if(a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline void init(vector<T> &v) {
	for(auto &a : v) cin >> a;
}
template<class T, class U> inline void init(vector<pair<T, U>> &v) {
	for(auto &a : v) cin >> a.first >> a.second;
}

template<class T> inline void init(vector<T> &v, int n) {
	v.resize(n);
	for(auto &a : v) cin >> a;
}
template<class T1, class T2> inline void init(vector<T1> &v1, vector<T2> &v2, int n) {
	v1.resize(n);
	v2.resize(n);
	for(int i = 0; i < n; i++) cin >> v1[i] >> v2[i];
}
template<class T1, class T2, class T3>
inline void init(vector<T1> &v1, vector<T2> &v2, vector<T3> &v3, int n) {
	v1.resize(n);
	v2.resize(n);
	v3.resize(n);
	for(int i = 0; i < n; i++) cin >> v1[i] >> v2[i] >> v3[i];
}
template<class T, class U> inline void init(vector<pair<T, U>> &v, int n) {
	v.resize(n);
	for(auto &a : v) cin >> a.first >> a.second;
}

template<class T> inline void init(vector<T> &v, int n, const T &c) {
	v.resize(n);
	for(auto &a : v) {
		cin >> a;
		a += c;
	}
}
template<class T1, class T2>
inline void init(vector<T1> &v1, vector<T2> &v2, int n, const T1 &c1, const T2 &c2) {
	v1.resize(n);
	v2.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> v1[i] >> v2[i];
		v1[i] += c1;
		v2[i] += c2;
	}
}
template<class T1, class T2, class T3>
inline void
init(vector<T1> &v1, vector<T2> &v2, vector<T3> &v3, int n, const T1 &c1, const T2 &c2, const T3 &c3) {
	v1.resize(n);
	v2.resize(n);
	v3.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> v1[i] >> v2[i] >> v3[i];
		v1[i] += c1;
		v2[i] += c2;
		v3[i] += c3;
	}
}
template<class T, class U> inline void init(vector<pair<T, U>> &v, int n, T &c1, U &c2) {
	v.resize(n);
	for(auto &a : v) {
		cin >> a.first >> a.second;
		a.first += c1;
		a.second += c2;
	}
}

inline void out() {
	cout << newl;
}
template<class T> inline void out(T a) {
	cout << a << '\n';
}
template<class T, class... U> inline void out(T a, U... lst) {
	cout << a << " ";
	out(forward<U>(lst)...);
}
template<class T> inline void out(vector<T> &v) {
	for(int i = 0; i < v.size(); i++) cout << v[i] << (i == v.size() - 1 ? '\n' : ' ');
	cout << flush;
}

template<class N> void resiz(N n) {}
template<class N, class T, class... U> void resiz(N n, T &&hd, U &&...tl) {
	hd.resize(n);
	resiz(n, forward<U>(tl)...);
}

bool Yes(bool b = true) {
	cout << (b ? "Yes" : "No") << newl;
	return b;
}
bool YES(bool b = true) {
	cout << (b ? "YES" : "NO") << newl;
	return b;
}
bool No(bool b = true) {
	if(!b) return false;
	cout << "No" << newl;
	return true;
}
bool NO(bool b = true) {
	if(!b) return false;
	cout << "NO" << newl;
	return true;
}

template<typename T> struct v2d {
private:
	vector<vector<T>> m;

public:
	v2d() {}
	v2d(int h, int w) : m(h, vector<T>(w)) {}
	v2d(int h, int w, const T &init) : m(h, vector<T>(w, init)) {}
	v2d(const initializer_list<initializer_list<T>> m_init) : m(m_init.begin(), m_init.end()) {}

	void assign(int h, int w) {
		m.assign(h, vector<T>(w));
	}
	void assign(int h, int w, const T init) {
		m.assign(h, vector<T>(w, init));
	}

	inline int size() const {
		return m.size();
	}

	void in() {
		for(vector<T> &v : m)
			for(T &val : v) cin >> val;
	}
	void in(int h, int w) {
		m.resize(h, vector<T>(w));
		in();
	}

	void out() {
		int h = m.size();
		for(vector<T> &v : m) {
			int sz = v.size();
			for(int j = 0; j < sz; j++) {
				cout << v[j] << (j == sz - 1 ? '\n' : ' ');
			}
		}
		cout << flush;
	}

	inline vector<T> &operator[](int idx) {
		assert(0 <= idx && idx < int(m.size()));
		return m[idx];
	}

	bool rangeout(int x, int y) {
		if(x < 0 || y < 0 || x >= size() || y >= m[x].size()) return true;
		return false;
	}
};

long long binpow(long long a, long long ex, long long p = MMPRIME) {
	long long res = 1;
	while(ex > 0) {
		if(ex & 1) (res *= a) %= p;
		ex >>= 1;
		(a *= a) %= p;
	}
	return res;
}

inline void init_e(v2d<int> &E, int n, int m, int c) {
	E.assign(n, 0);
	int u, v;
	for(int i = 0; i < m; i++) {
		cin >> u >> v;
		u += c;
		v += c;
		E[u].emplace_back(v);
		E[v].emplace_back(u);
	}
}

// -------------------- main code -------------------- //


int na, nb, nc;
vint A, B, C;
vlint sumA, sumB, sumC;
lint ans = -LLINF;

void input() {
	cin >> na >> nb >> nc;
	init(A, na);
	init(B, nb);
	init(C, nc);
}

lint score(int i, int j) {
	lint sb = sumB[i];
	int ok = 0, ng = nc + 1;
	while(ng - ok > 1) {
		int mid = (ok + ng) / 2;
		if(sb + lint(C[mid - 1]) * i >= 0) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	int k = ok;
	return sumA[i] * j + sumB[j] * k + sumC[k] * i;
}

void solve() {
	sort(rall(A));
	sort(rall(B));
	sort(rall(C));
	sumA.resize(na + 1, 0), sumB.resize(nb + 1, 0), sumC.resize(nc + 1, 0);
	for(int i = 0; i < na; i++) sumA[i + 1] = sumA[i] + A[i];
	for(int i = 0; i < nb; i++) sumB[i + 1] = sumB[i] + B[i];
	for(int i = 0; i < nc; i++) sumC[i + 1] = sumC[i] + C[i];

	for(int i = 0; i <= na; i++) {
		dbg(i);
		int l = -1, r = nb + 1;
		while(r - l > 2) {
			int midl = (l * 2 + r) / 3;
			int midr = (l + r * 2) / 3;
			if(score(i, midl) > score(i, midr)) {
				r = midr;
				dbg(midl);
				dbg(r);
			}
			else {
				dbg(midr);
				l = midl;
				dbg(l);
			}
		}
		chmax(ans, score(i, (l + r) / 2));
	}

	out(ans);
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	int t = 1;
	// cin >> t;
	while(t--) {
		input();
		solve();
	}
}
0