結果

問題 No.2261 Coffee
ユーザー HIcoder
提出日時 2023-07-06 22:08:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 497 ms / 2,000 ms
コード長 1,164 bytes
コンパイル時間 984 ms
コンパイル使用メモリ 102,940 KB
最終ジャッジ日時 2025-02-15 06:27:46
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
方針を聞いてAC
*/
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);

int main(){
    int N;
    cin>>N;
    vector<vector<ll>> A(N,vector<ll>(5));
    for(int i=0;i<N;i++){
        for(int j=0;j<5;j++){
            cin>>A[i][j];
        }
    }

    vector<ll> ans(N);
    const int r=5;

    for(int S=0;S<(1<<r);S++){
        
        ll candmax=-INF,candmin=INF;
        vector<ll> F(N,0);
        for(int i=0;i<N;i++){
            for(int t=0;t<r;t++){
                if((S>>t)&1){
                    F[i]-=A[i][t];
                }else{
                    F[i]+=A[i][t];
                }
            }
            candmax=max(candmax,F[i]);
            candmin=max(candmin,F[i]);
        }

        for(int i=0;i<N;i++){
            ans[i]=max({ans[i],candmax-F[i],F[i]-candmin});
        }

    }

    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }


  

}
0