結果

問題 No.2495 Three Sets
ユーザー 蜜蜂蜜蜂
提出日時 2023-10-13 11:22:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,139 ms / 3,000 ms
コード長 1,852 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 175,544 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-13 11:23:14
合計ジャッジ時間 21,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 628 ms
4,372 KB
testcase_01 AC 664 ms
4,372 KB
testcase_02 AC 992 ms
4,368 KB
testcase_03 AC 643 ms
4,372 KB
testcase_04 AC 639 ms
4,372 KB
testcase_05 AC 638 ms
4,368 KB
testcase_06 AC 703 ms
4,372 KB
testcase_07 AC 1,078 ms
4,368 KB
testcase_08 AC 1,049 ms
4,368 KB
testcase_09 AC 644 ms
4,368 KB
testcase_10 AC 644 ms
4,368 KB
testcase_11 AC 1,124 ms
4,372 KB
testcase_12 AC 1,107 ms
4,372 KB
testcase_13 AC 1,060 ms
4,368 KB
testcase_14 AC 1,139 ms
4,368 KB
testcase_15 AC 1,105 ms
4,368 KB
testcase_16 AC 1,117 ms
4,368 KB
testcase_17 AC 1,130 ms
4,372 KB
testcase_18 AC 136 ms
4,368 KB
testcase_19 AC 163 ms
4,372 KB
testcase_20 AC 1,138 ms
4,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:66:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   66 |       auto [sumb,cntb]=v[1][i];
      |            ^
main.cpp:67:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   67 |       auto [sumc,cntc]=v[2][j];
      |            ^
main.cpp:82:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   82 |         auto [suma,cnta]=v[0][k];
      |              ^

ソースコード

diff #

// g++-13 1.cpp -std=c++17 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/dsu>
#include <atcoder/modint>
using namespace atcoder;

using ll = long long;
using ld = long double;
 
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vst = vector<string>;
using vvst = vector<vst>;
 
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int na,nb,nc;cin>>na>>nb>>nc;
  vvi cnt(3,vi(7000,0));

  rep(i,0,na){
    int x;cin>>x;
    cnt[0][x+3500]++;
  }
  rep(i,0,nb){
    int x;cin>>x;
    cnt[1][x+3500]++;
  }
  rep(i,0,nc){
    int x;cin>>x;
    cnt[2][x+3500]++;
  }

  vector<vector<pair<ll,int>>> v(3,vector<pair<ll,int>>(7000,{0,0}));

  per(i,6998,0){
    rep(j,0,3){
      v[j][i]=v[j][i+1];
      v[j][i].first+=(ll)cnt[j][i]*(i-3500);
      v[j][i].second+=cnt[j][i];
    }
  }

  ll ans=0;
  rep(i,0,7000){
    rep(j,0,7000){
      // A_i >= - sum(C_i) / |S_B|
      auto [sumb,cntb]=v[1][i];
      auto [sumc,cntc]=v[2][j];

      if(cntb==0){
        ans=max(ans,na*sumc);
        continue;
      }

      ll need=(-sumc+cntb-1)/cntb;
      need+=3500;

      if(need<0)need=0;
      if(6999<=need)need=6999;

      rep(k,need-2,need+2){
        if(k<0||7000<=k)continue;
        auto [suma,cnta]=v[0][k];
        ans=max(ans,suma*cntb+sumb*cntc+sumc*cnta);
      }
    }
  }

  cout<<ans<<endl;
}
0