結果
問題 | No.2261 Coffee |
ユーザー |
|
提出日時 | 2023-04-07 22:24:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 1,421 bytes |
コンパイル時間 | 782 ms |
コンパイル使用メモリ | 78,972 KB |
最終ジャッジ日時 | 2025-02-12 01:47:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} ll d(int x,int y,vector<vector<ll>>&A){ ll dist=0; rep(i,5)dist+=abs(A[x][i]-A[y][i]); return dist; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vector<vector<ll>>A(n,vector<ll>(5)); rep(i,n)rep(j,5)cin>>A[i][j]; ll ans=0; vector<ll>M(1<<5,-1LL<<60),m(1<<5,1LL<<60); rep(i,n){ rep(s,1<<5){ ll p=0; rep(j,5){ if(s>>j&1){ p+=A[i][j]; }else{ p-=A[i][j]; } } chmax(M[s],p); chmin(m[s],p); } } rep(i,n){ ll ans=-1LL<<60; rep(s,1<<5){ ll p=0; rep(j,5){ if(s>>j&1){ p+=A[i][j]; }else{ p-=A[i][j]; } } chmax(ans,M[s]-p); chmax(ans,p-m[s]); } cout<<ans<<"\n"; } }