結果

問題 No.2261 Coffee
ユーザー boatmusclesboatmuscles
提出日時 2023-04-08 14:35:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,443 bytes
コンパイル時間 4,477 ms
コンパイル使用メモリ 249,604 KB
実行使用メモリ 32,748 KB
最終ジャッジ日時 2024-04-14 12:09:02
合計ジャッジ時間 12,534 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 7 ms
6,944 KB
testcase_18 AC 6 ms
6,944 KB
testcase_19 AC 6 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,940 KB
testcase_24 AC 133 ms
32,296 KB
testcase_25 AC 115 ms
28,488 KB
testcase_26 AC 143 ms
32,688 KB
testcase_27 AC 133 ms
32,364 KB
testcase_28 AC 92 ms
30,536 KB
testcase_29 AC 86 ms
29,896 KB
testcase_30 AC 66 ms
24,520 KB
testcase_31 AC 106 ms
32,512 KB
testcase_32 AC 107 ms
32,632 KB
testcase_33 AC 107 ms
32,696 KB
testcase_34 AC 107 ms
32,660 KB
testcase_35 AC 106 ms
32,536 KB
testcase_36 AC 107 ms
32,576 KB
testcase_37 AC 106 ms
32,632 KB
testcase_38 AC 143 ms
32,572 KB
testcase_39 AC 144 ms
32,472 KB
testcase_40 AC 143 ms
32,612 KB
testcase_41 AC 144 ms
32,704 KB
testcase_42 AC 144 ms
32,528 KB
testcase_43 AC 143 ms
32,748 KB
testcase_44 AC 145 ms
32,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/extc++.h>
//#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rep2(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rrep2(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); --i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int MAX_N = 100000;
constexpr ll INF = 6000000000000000;
ll A[MAX_N][5];
ll min_right[MAX_N][32];
int main(){
    int N;
    scanf("%d", &N);
    rep(i, N) rep(j, 5) scanf("%lld", &A[i][j]);
    fill(min_right[N-1],min_right[N-1]+32,INF);
    rrep(i, N){
        if(i){
            copy(min_right[i],min_right[i]+32,min_right[i-1]);
            rep(j, 32){
                ll sum = 0;
                rep(k, 5) sum += j>>k&1 ? A[i][k] : -A[i][k];
                chmin(min_right[i-1][j], sum);
            }
        }
    }
    ll min_left[32];
    fill(min_left,min_left+32,INF);
    rep(i, N){
        ll ans = 0;
        rep(j, 32){
            ll sum = 0;
            rep(k, 5) sum += j>>k&1 ? A[i][k] : -A[i][k];
            chmax(ans, sum - min(min_left[j], min_right[i][j]));
            chmin(min_left[j], sum);
        }
        printf("%lld\n", ans);
    }
    return 0;
}
0