結果
問題 |
No.2495 Three Sets
|
ユーザー |
|
提出日時 | 2023-10-06 22:24:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,195 bytes |
コンパイル時間 | 1,838 ms |
コンパイル使用メモリ | 178,548 KB |
実行使用メモリ | 814,592 KB |
最終ジャッジ日時 | 2024-07-26 16:35:39 |
合計ジャッジ時間 | 3,877 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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>> diff(Na+1,vector<long long>(Nc)); for(int i=0; i<=Na; i++){ for(int k=0; k<Nc; k++){ diff.at(i).at(k) = -i*C.at(k); if(k) diff.at(i).at(k) += i*C.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; }