結果
| 問題 |
No.2261 Coffee
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-07 21:27:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 207 ms / 2,000 ms |
| コード長 | 943 bytes |
| コンパイル時間 | 2,266 ms |
| コンパイル使用メモリ | 196,748 KB |
| 最終ジャッジ日時 | 2025-02-12 00:21:45 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
std::vector<std::array<i64, 5>> A(N);
std::vector<i64> max(32, -1E18);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 5; j++) {
std::cin >> A[i][j];
}
for (int s = 0; s < 32; s++) {
i64 v = 0;
for (int j = 0; j < 5; j++) {
v += (s >> j & 1 ? 1 : -1) * A[i][j];
}
max[s] = std::max(max[s], v);
}
}
for (int i = 0; i < N; i++) {
i64 ans = -1E18;
for (int s = 0; s < 32; s++) {
i64 v = 0;
for (int j = 0; j < 5; j++) {
v += (s >> j & 1 ? 1 : -1) * A[i][j];
}
ans = std::max(ans, v + max[s ^ 31]);
}
std::cout << ans << "\n";
}
return 0;
}