結果

問題 No.2495 Three Sets
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-06 22:33:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,328 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 176,252 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2023-10-06 22:33:49
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 10 ms
5,368 KB
testcase_11 AC 9 ms
4,600 KB
testcase_12 AC 19 ms
5,756 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 173 ms
76,056 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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,1),B(Nb,2),C(Nc,3);
    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(Nc,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