結果
問題 | No.2261 Coffee |
ユーザー |
|
提出日時 | 2023-04-07 23:08:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 574 ms / 2,000 ms |
コード長 | 1,250 bytes |
コンパイル時間 | 2,520 ms |
コンパイル使用メモリ | 202,792 KB |
最終ジャッジ日時 | 2025-02-12 02:33:44 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;vector<ll> c(vector<ll> &p) {int k = p.size();vector<ll> res;for (int bit = 0; bit < (1 << k); bit++) {ll tmp = 0;for (int i = 0; i < k; i++) {if (bit & (1 << i)) {tmp += p[i];} else {tmp -= p[i];}}res.push_back(tmp);}return res;}int main() {int N;cin >> N;vector<vector<ll>> param(N, vector<ll>(5));for (int i = 0; i < N; i++) {for (int j = 0; j < 5; j++) {cin >> param[i][j];}}ll inf = 1LL << 60;vector<ll> m(32, inf), M(32, -inf);vector<vector<ll>> chs(N);for (int i = 0; i < N; i++) {auto ch = c(param[i]);chs[i] = ch;for (int j = 0; j < 32; j++) {m[j] = min(m[j], ch[j]);M[j] = max(M[j], ch[j]);}}vector<ll> ans(N);for (int k = 0; k < N; k++) {for (int j = 0; j < 32; j++) {ans[k] =max({ans[k], abs(chs[k][j] - m[j]), abs(chs[k][j] - M[j])});}}for (int i = 0; i < N; i++) {cout << ans[i] << endl;}return 0;}