結果

問題 No.2495 Three Sets
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-11 01:33:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,596 bytes
コンパイル時間 7,298 ms
コンパイル使用メモリ 168,120 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-10-11 01:34:16
合計ジャッジ時間 17,731 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 291 ms
4,368 KB
testcase_01 AC 291 ms
4,372 KB
testcase_02 AC 509 ms
4,372 KB
testcase_03 AC 293 ms
4,368 KB
testcase_04 AC 292 ms
4,368 KB
testcase_05 AC 297 ms
4,372 KB
testcase_06 AC 457 ms
4,368 KB
testcase_07 AC 488 ms
4,368 KB
testcase_08 AC 522 ms
4,372 KB
testcase_09 AC 299 ms
4,368 KB
testcase_10 AC 297 ms
4,372 KB
testcase_11 AC 525 ms
4,368 KB
testcase_12 AC 502 ms
4,372 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 512 ms
4,372 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 84 ms
4,372 KB
testcase_19 AC 108 ms
4,368 KB
testcase_20 AC 547 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

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> suma(6009),sumb(6009),sumc(6009),Va(6009),Vb(6009),Vc(6009);
    for(int i=0; i<Na; i++){
        int a; cin >> a;
        suma.at(a+3000) += a;
        Va.at(a+3000)++; 
    }
    for(int i=0; i<Nb; i++){
        int b; cin >> b;
        sumb.at(b+3000) += b;
        Vb.at(b+3000)++;
    }
    for(int i=0; i<Nc; i++){
        int c; cin >> c; 
        sumc.at(c+3000) += c;
        Vc.at(c+3000)++;
    }

    for(int i=6007; i>=0; i--) Va.at(i) += Va.at(i+1);
    for(int i=6007; i>=0; i--) Vb.at(i) += Vb.at(i+1);
    for(int i=6007; i>=0; i--) Vc.at(i) += Vc.at(i+1);
    for(int i=6007; i>=0; i--) suma.at(i) += suma.at(i+1);
    for(int i=6007; i>=0; i--) sumb.at(i) += sumb.at(i+1);
    for(int i=6007; i>=0; i--) sumc.at(i) += sumc.at(i+1);


    long long answer = 0;
    for(int i=0; i<=6000; i++){
        long long sa = suma.at(i), va = Va.at(i);
        for(int k=0; k<=6000; k++){
            long long sb = sumb.at(k),vb = Vb.at(k);
            long long now = sa*vb;
            if(va == 0){
                answer = max({answer,now,now+sb*Nc});
                continue;
            }

            long long border = (-sb+va-1)/va;
            if(border > 3000) border = 3001;
            if(border < -3000) border = -3000; 
            long long sc = sumc.at(border+3000),vc = Vc.at(border+3000);
            answer = max(answer,now+sc*va+sb*vc);
        }
    }
    cout << answer << endl;
}
0