結果
| 問題 |
No.2261 Coffee
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-07 21:54:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 1,191 bytes |
| コンパイル時間 | 2,150 ms |
| コンパイル使用メモリ | 198,836 KB |
| 最終ジャッジ日時 | 2025-02-12 01:13:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
V<V<long long>> A(5, V<long long>(N));
rep(i, N) rep(j, 5) cin >> A[j][i];
const int M = 5, M2 = 1 << 5;
const long long INF = 1LL << 60;
V<long long> S(M2, -INF);
rep(i, N) {
rep(bit, M2) {
long long c = 0;
rep(j, 5) {
if (bit >> j & 1) {
c += A[j][i];
} else {
c -= A[j][i];
}
}
S[bit] = max(S[bit], c);
}
}
rep(i, N) {
long long ans = -INF;
rep(bit, M2) {
long long c = 0;
rep(j, 5) {
if (bit >> j & 1) {
c -= A[j][i];
} else {
c += A[j][i];
}
}
ans = max(ans, c + S[bit]);
}
cout << ans << '\n';
}
return 0;
}