結果
| 問題 |
No.2495 Three Sets
|
| ユーザー |
Kude
|
| 提出日時 | 2023-10-06 22:17:50 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,647 bytes |
| コンパイル時間 | 3,249 ms |
| コンパイル使用メモリ | 278,828 KB |
| 実行使用メモリ | 11,808 KB |
| 最終ジャッジ日時 | 2024-07-26 16:31:12 |
| 合計ジャッジ時間 | 8,145 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 7 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n[3];
rep(i, 3) cin >> n[i];
VL a[3];
rep(i, 3) {
a[i].resize(n[i]);
rep(j, n[i]) cin >> a[i][j];
sort(all(a[i]));
}
VL s[3];
rep(i, 3) {
s[i].resize(n[i] + 1);
rep(j, n[i]) s[i][j+1] = s[i][j] + a[i][j];
}
ll ans = 0;
constexpr int INF = 1001001001;
rep(c0, n[0] + 1) rep(c2, n[2] + 1) {
ll s0 = s[0][n[0]] - s[0][n[0] - c0];
ll s2 = s[2][n[2]] - s[2][n[2] - c2];
auto flr = [&](ll x, int y) {
if (x >= 0) return x / y;
else return -((-x + y - 1) / y);
};
ll v1 = [&]() -> ll {
if (c2 == 0) {
return s0 > 0 ? -INF : INF;
}
return flr(-s0, c2);
}();
int i1 = upper_bound(all(a[1]), v1) - a[1].begin();
int c1 = n[1] - i1;
ll s1 = s[1][n[1]] - s[1][n[1] - c1];
chmax(ans, s0 * c1 + s1 * c2 + s2 * c0);
}
cout << ans << '\n';
}
Kude