結果
問題 |
No.2261 Coffee
|
ユーザー |
![]() |
提出日時 | 2023-05-18 19:36:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,013 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 42,820 KB |
実行使用メモリ | 7,168 KB |
最終ジャッジ日時 | 2024-12-16 08:42:06 |
合計ジャッジ時間 | 8,334 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
/* -*- coding: utf-8 -*- * * 2261.cc: No.2261 Coffee - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100000; const int M = 5; const int MBITS = 1 << M; const int MMSK = MBITS - 1; /* typedef */ typedef long long ll; /* global variables */ ll ps[MAX_N][M], mxss[MBITS]; /* subroutines */ ll calc(ll es[], int bits) { ll sum = 0; for (int i = 0, bi = 1; i < M; i++, bi <<= 1) sum += es[i] * ((bits & bi) ? -1 : 1); return sum; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < M; j++) scanf("%lld", &ps[i][j]); for (int bits = 0; bits < MBITS; bits++) { mxss[bits] = -(1LL << 62); for (int i = 0; i < n; i++) mxss[bits] = max(mxss[bits], calc(ps[i], bits)); } for (int i = 0; i < n; i++) { ll mx = 0; for (int bits = 0; bits < MBITS; bits++) mx = max(mx, mxss[bits] - calc(ps[i], bits)); printf("%lld\n", mx); } return 0; }