結果

問題 No.2261 Coffee
ユーザー RubikunRubikun
提出日時 2023-04-07 21:28:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 1,491 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 204,248 KB
実行使用メモリ 97,144 KB
最終ジャッジ日時 2024-04-10 16:36:24
合計ジャッジ時間 8,894 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,948 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 7 ms
6,940 KB
testcase_18 AC 6 ms
6,940 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 5 ms
6,940 KB
testcase_21 AC 7 ms
6,944 KB
testcase_22 AC 5 ms
6,944 KB
testcase_23 AC 6 ms
6,944 KB
testcase_24 AC 193 ms
90,456 KB
testcase_25 AC 163 ms
78,080 KB
testcase_26 AC 202 ms
96,384 KB
testcase_27 AC 188 ms
89,344 KB
testcase_28 AC 128 ms
81,664 KB
testcase_29 AC 125 ms
80,000 KB
testcase_30 AC 100 ms
63,232 KB
testcase_31 AC 156 ms
97,144 KB
testcase_32 AC 161 ms
97,024 KB
testcase_33 AC 161 ms
97,024 KB
testcase_34 AC 156 ms
97,024 KB
testcase_35 AC 158 ms
97,140 KB
testcase_36 AC 157 ms
97,108 KB
testcase_37 AC 159 ms
97,024 KB
testcase_38 AC 215 ms
96,956 KB
testcase_39 AC 205 ms
97,016 KB
testcase_40 AC 206 ms
97,024 KB
testcase_41 AC 204 ms
97,060 KB
testcase_42 AC 208 ms
97,024 KB
testcase_43 AC 204 ms
96,964 KB
testcase_44 AC 204 ms
96,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<vector<ll>> S(N,vector<ll>(5));
    for(int i=0;i<N;i++){
        for(int j=0;j<5;j++) cin>>S[i][j];
    }
    
    vector<vector<ll>> Lma(N+2,vector<ll>(1<<5,-(1LL<<60))),Rma,T;
    
    for(int i=0;i<N;i++){
        for(int x=0;x<(1<<5);x++){
            ll sum=0;
            for(int k=0;k<5;k++){
                if(x&(1<<k)) sum+=S[i][k];
                else sum-=S[i][k];
            }
            Lma[i+1][x]=sum;
        }
    }
    
    Rma=Lma;
    T=Lma;
    
    for(int i=1;i<=N+1;i++){
        for(int x=0;x<(1<<5);x++) chmax(Lma[i][x],Lma[i-1][x]);
    }
    for(int i=N;i>=0;i--){
        for(int x=0;x<(1<<5);x++) chmax(Rma[i][x],Rma[i+1][x]);
    }
    
    for(int s=1;s<=N;s++){
        ll ans=-(1LL<<60);
        for(int x=0;x<(1<<5);x++){
            chmax(ans,T[s][x]+Lma[s-1][31-x]);
            chmax(ans,T[s][x]+Rma[s+1][31-x]);
        }
        cout<<ans<<"\n";
    }
}
0