結果

問題 No.2495 Three Sets
ユーザー GOTKAKO
提出日時 2023-10-06 22:30:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,322 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 178,892 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-07-26 16:37:39
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 6 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(min(Na,3000)+1,vector<long long>(min(Nc,3000)));
    for(int i=0; i<=min(Na,3000); i++){
        for(int k=0; k<min(Nb,3000); 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<=min(Na,3000); i++){
        for(int k=0; k<=min(Nb,3000); k++){
            if(i+k > 3000) break;
            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();
            l = min(l,3000-i-k);
            if(l) c = C.at(l-1);

            answer = max(answer,a*k+b*l+c*i);
        }
    }
    cout << answer << endl;
}
0