結果

問題 No.2261 Coffee
ユーザー 👑 chro_96chro_96
提出日時 2023-04-07 21:57:36
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 488 ms / 2,000 ms
コード長 1,204 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 31,580 KB
最終ジャッジ日時 2024-04-10 17:02:51
合計ジャッジ時間 12,627 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
30,720 KB
testcase_01 AC 8 ms
30,784 KB
testcase_02 AC 8 ms
30,720 KB
testcase_03 AC 8 ms
30,680 KB
testcase_04 AC 8 ms
30,740 KB
testcase_05 AC 9 ms
30,716 KB
testcase_06 AC 8 ms
30,720 KB
testcase_07 AC 8 ms
30,692 KB
testcase_08 AC 8 ms
30,764 KB
testcase_09 AC 8 ms
30,680 KB
testcase_10 AC 10 ms
30,696 KB
testcase_11 AC 9 ms
30,708 KB
testcase_12 AC 9 ms
30,704 KB
testcase_13 AC 9 ms
30,760 KB
testcase_14 AC 9 ms
30,632 KB
testcase_15 AC 8 ms
30,816 KB
testcase_16 AC 8 ms
30,688 KB
testcase_17 AC 19 ms
30,752 KB
testcase_18 AC 18 ms
30,640 KB
testcase_19 AC 18 ms
30,756 KB
testcase_20 AC 15 ms
30,700 KB
testcase_21 AC 19 ms
30,720 KB
testcase_22 AC 16 ms
30,688 KB
testcase_23 AC 19 ms
30,720 KB
testcase_24 AC 448 ms
31,448 KB
testcase_25 AC 385 ms
31,300 KB
testcase_26 AC 476 ms
31,572 KB
testcase_27 AC 454 ms
31,328 KB
testcase_28 AC 317 ms
31,444 KB
testcase_29 AC 314 ms
31,316 KB
testcase_30 AC 238 ms
31,196 KB
testcase_31 AC 407 ms
31,572 KB
testcase_32 AC 388 ms
31,576 KB
testcase_33 AC 391 ms
31,576 KB
testcase_34 AC 400 ms
31,572 KB
testcase_35 AC 391 ms
31,580 KB
testcase_36 AC 404 ms
31,572 KB
testcase_37 AC 403 ms
31,580 KB
testcase_38 AC 479 ms
31,572 KB
testcase_39 AC 479 ms
31,576 KB
testcase_40 AC 488 ms
31,580 KB
testcase_41 AC 484 ms
31,576 KB
testcase_42 AC 484 ms
31,576 KB
testcase_43 AC 483 ms
31,576 KB
testcase_44 AC 483 ms
31,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int cmp_ll (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 n = 0;
  long long abcde[100000][5] = {};
  
  int res = 0;
  
  long long s[32][100000] = {};
  
  res = scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      res = scanf("%lld", abcde[i]+j);
    }
  }
  
  for (int i = 0; i < 32; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 5; k++) {
        if ((i&(1<<k)) > 0) {
          s[i][j] -= abcde[j][k];
        } else {
          s[i][j] += abcde[j][k];
        }
      }
    }
    qsort(s[i], n, sizeof(long long), cmp_ll);
  }
  
  for (int i = 0; i < n; i++) {
  long long ans = 0LL;
    for (int j = 0; j < 32; j++) {
      long long tmp = 0LL;
      for (int k = 0; k < 5; k++) {
        if ((j&(1<<k)) > 0) {
          tmp -= abcde[i][k];
        } else {
          tmp += abcde[i][k];
        }
      }
      if (s[j][n-1]-tmp > ans) {
        ans = s[j][n-1]-tmp;
      }
    }
    printf("%lld\n", ans);
  }
  
  return 0;
}
0