結果
| 問題 |
No.2495 Three Sets
|
| ユーザー |
|
| 提出日時 | 2023-10-06 22:20:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,321 bytes |
| コンパイル時間 | 1,983 ms |
| コンパイル使用メモリ | 178,260 KB |
| 実行使用メモリ | 818,048 KB |
| 最終ジャッジ日時 | 2024-07-26 16:33:39 |
| 合計ジャッジ時間 | 4,480 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 MLE * 1 -- * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int Na,Nb,Nc; cin >> Na >> Nb >> Nc;
vector<long long> A(Na),B(Nb),C(Nc);
for(auto &a : A) cin >> a;
for(auto &b : B) cin >> b;
for(auto &c : C) cin >> c;
sort(A.rbegin(),A.rend());
sort(B.rbegin(),B.rend());
sort(C.rbegin(),C.rend());
for(int i=1; i<Na; i++) A.at(i) += A.at(i-1);
for(int i=1; i<Nb; i++) B.at(i) += B.at(i-1);
for(int i=1; i<Nc; i++) C.at(i) += C.at(i-1);
vector<vector<long long>> ci(Na+1,vector<long long>(Nc+1)),diff(Na+1,vector<long long>(Nc));
for(int i=0; i<=Na; i++){
for(int k=1; k<=Nc; k++){
ci.at(i).at(k) = i*C.at(k-1);
}
}
for(int i=0; i<=Na; i++){
for(int k=0; k<Nc; k++){
diff.at(i).at(k) = ci.at(i).at(k)-ci.at(i).at(k+1);
}
}
long long answer = 0;
for(int i=0; i<=Na; i++){
for(int k=0; k<=Nb; k++){
long long a = 0,b = 0,c = 0;
if(i) a = A.at(i-1);
if(k) b = B.at(k-1);
int l = lower_bound(diff.at(i).begin(),diff.at(i).end(),b)-diff.at(i).begin();
if(l) c = C.at(l-1);
answer = max(answer,a*k+b*l+c*i);
}
}
cout << answer << endl;
}