結果

問題 No.2495 Three Sets
ユーザー 👑 chro_96chro_96
提出日時 2023-10-06 23:42:31
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,686 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 30,284 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-10-06 23:42:39
合計ジャッジ時間 7,395 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,472 KB
testcase_01 AC 2 ms
6,476 KB
testcase_02 AC 3 ms
6,604 KB
testcase_03 AC 3 ms
6,472 KB
testcase_04 AC 3 ms
6,504 KB
testcase_05 AC 3 ms
6,412 KB
testcase_06 AC 3 ms
6,564 KB
testcase_07 AC 2 ms
6,468 KB
testcase_08 AC 2 ms
6,520 KB
testcase_09 AC 3 ms
6,600 KB
testcase_10 AC 5 ms
6,588 KB
testcase_11 AC 4 ms
6,600 KB
testcase_12 AC 5 ms
6,412 KB
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int cmp_ll_rev (const void *ap, const void *bp) {
  long long a = *(long long *)ap;
  long long b = *(long long *)bp;
  
  if (a < b) {
    return 1;
  }
  
  if (a > b) {
    return -1;
  }
  
  return 0;
}

int main () {
  int na = 0;
  int nb = 0;
  int nc = 0;
  long long a[100000] = {};
  long long b[100000] = {};
  long long c[100000] = {};
  
  int res = 0;
  
  long long ans = 0LL;
  
  long long sum_a[100001] = {};
  long long sum_b[100001] = {};
  long long sum_c[100001] = {};
  
  int idx_b = 0;
  
  res = scanf("%d", &na);
  res = scanf("%d", &nb);
  res = scanf("%d", &nc);
  for (int i = 0; i < na; i++) {
    res = scanf("%lld", a+i);
  }
  for (int i = 0; i < nb; i++) {
    res = scanf("%lld", b+i);
  }
  for (int i = 0; i < nc; i++) {
    res = scanf("%lld", c+i);
  }
  
  qsort(a, na, sizeof(long long), cmp_ll_rev);
  qsort(b, nb, sizeof(long long), cmp_ll_rev);
  qsort(c, nc, sizeof(long long), cmp_ll_rev);
  
  for (int i = 0; i < na; i++) {
    sum_a[i+1] = a[i]+sum_a[i];
  }
  for (int i = 0; i < nb; i++) {
    sum_b[i+1] = b[i]+sum_b[i];
  }
  for (int i = 0; i < nc; i++) {
    sum_c[i+1] = c[i]+sum_c[i];
  }
  
  while (idx_b < nb-1 && b[idx_b+1] >= 0LL) {
    idx_b++;
  }
  
  for (int i = 0; i <= na; i++) {
    int idx = 0;
    for (int j = nb; j >= idx_b; j--) {
      while (idx < nc && c[idx]*((long long)i)*(-1LL) <= sum_b[j]) {
        idx++;
      }
      if (sum_a[i]*((long long)j)+sum_b[j]*((long long)idx)+sum_c[idx]*((long long)i) > ans) {
        ans = sum_a[i]*((long long)j)+sum_b[j]*((long long)idx)+sum_c[idx]*((long long)i);
      }
    }
  }
  
  printf("%lld\n", ans);
  return 0;
}
0