結果

問題 No.2495 Three Sets
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-11 01:36:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 538 ms / 3,000 ms
コード長 1,636 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 169,896 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 01:37:04
合計ジャッジ時間 11,967 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
4,372 KB
testcase_01 AC 287 ms
4,368 KB
testcase_02 AC 469 ms
4,376 KB
testcase_03 AC 315 ms
4,368 KB
testcase_04 AC 294 ms
4,368 KB
testcase_05 AC 298 ms
4,372 KB
testcase_06 AC 473 ms
4,372 KB
testcase_07 AC 471 ms
4,376 KB
testcase_08 AC 479 ms
4,376 KB
testcase_09 AC 318 ms
4,368 KB
testcase_10 AC 301 ms
4,372 KB
testcase_11 AC 483 ms
4,372 KB
testcase_12 AC 507 ms
4,376 KB
testcase_13 AC 492 ms
4,372 KB
testcase_14 AC 501 ms
4,372 KB
testcase_15 AC 499 ms
4,372 KB
testcase_16 AC 508 ms
4,368 KB
testcase_17 AC 538 ms
4,372 KB
testcase_18 AC 84 ms
4,372 KB
testcase_19 AC 109 ms
4,372 KB
testcase_20 AC 503 ms
4,368 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(sb > 0) border = -sb/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