結果
| 問題 |
No.2261 Coffee
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-07 21:46:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 2,000 ms |
| コード長 | 1,211 bytes |
| コンパイル時間 | 1,720 ms |
| コンパイル使用メモリ | 171,304 KB |
| 実行使用メモリ | 32,256 KB |
| 最終ジャッジ日時 | 2024-10-02 19:19:45 |
| 合計ジャッジ時間 | 7,153 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<vector<long long>> a(n, vector<long long>(32));
vector<long long> mx(32), mi(32);
for (int i = 0; i < n; i++) {
vector<long long> b(5);
for (int j = 0; j < 5; j++) {
cin >> b[j];
}
for (int j = 0; j < (1 << 5); j++) {
long long sum = 0;
for (int k = 0; k < 5; k++) {
if ((j >> k) & 1) {
sum += b[k];
} else {
sum -= b[k];
}
}
a[i][j] = sum;
}
for (int j = 0; j < (1 << 5); j++) {
if (i == 0) {
mx[j] = a[i][j];
mi[j] = a[i][j];
} else {
mx[j] = max(mx[j], a[i][j]);
mi[j] = min(mi[j], a[i][j]);
}
}
}
for (int i = 0; i < n; i++) {
long long ans = 0;
for (int j = 0; j < (1 << 5); j++) {
ans = max(ans, mx[j] - a[i][j]);
ans = max(ans, a[i][j] - mi[j]);
}
cout << ans << '\n';
}
}