結果
問題 | No.2261 Coffee |
ユーザー | wanui |
提出日時 | 2023-04-07 22:30:38 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 112 ms / 2,000 ms |
コード長 | 2,427 bytes |
コンパイル時間 | 2,194 ms |
コンパイル使用メモリ | 208,264 KB |
実行使用メモリ | 7,220 KB |
最終ジャッジ日時 | 2024-10-02 19:56:54 |
合計ジャッジ時間 | 7,229 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18; void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);} void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);} void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);} void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); } #define debug1(a) { cerr<<#a<<":"<<a<<endl; } #define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; } #define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; } #define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; } // clang-format on struct coffee { ll a; ll b; ll c; ll d; ll e; }; int main() { ioinit(); vector<ll> maxs; ll N; cin >> N; vector<coffee> cofs(N); for (ll i = 0; i < N; i++) { coffee c; cin >> c.a >> c.b >> c.c >> c.d >> c.e; cofs[i] = c; } for (ll bin = 0; bin < 32; bin++) { coffee base; for (ll j = 0; j < 5; j++) { ll x = 0; if ((bin >> j) & 1) { x = 1001001001001001; } if (j == 0) base.a = x; if (j == 1) base.b = x; if (j == 2) base.c = x; if (j == 3) base.d = x; if (j == 4) base.e = x; } pll mx = {-1, -1}; for (ll i = 0; i < N; i++) { coffee c = cofs[i]; ll diff = abs(base.a - c.a) + abs(base.b - c.b) + abs(base.c - c.c) + abs(base.d - c.d) + abs(base.e - c.e); pll cur = {diff, i}; mx = max(cur, mx); } maxs.push_back(mx.second); } for (ll i = 0; i < N; i++) { ll ans = 0; for (auto j : maxs) { coffee c = cofs[i]; coffee d = cofs[j]; ll diff = abs(d.a - c.a) + abs(d.b - c.b) + abs(d.c - c.c) + abs(d.d - c.d) + abs(d.e - c.e); ans = max(diff, ans); } print(ans); } return 0; }