結果

問題 No.2261 Coffee
ユーザー SSRSSSRS
提出日時 2023-04-07 21:24:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 501 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 169,080 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-10 16:32:43
合計ジャッジ時間 12,815 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 15 ms
5,376 KB
testcase_22 AC 11 ms
5,376 KB
testcase_23 AC 16 ms
5,376 KB
testcase_24 AC 463 ms
12,708 KB
testcase_25 AC 401 ms
11,292 KB
testcase_26 AC 497 ms
13,340 KB
testcase_27 AC 460 ms
12,580 KB
testcase_28 AC 238 ms
11,904 KB
testcase_29 AC 239 ms
11,520 KB
testcase_30 AC 184 ms
9,728 KB
testcase_31 AC 302 ms
13,400 KB
testcase_32 AC 307 ms
13,416 KB
testcase_33 AC 302 ms
13,568 KB
testcase_34 AC 303 ms
13,568 KB
testcase_35 AC 295 ms
13,440 KB
testcase_36 AC 307 ms
13,568 KB
testcase_37 AC 302 ms
13,536 KB
testcase_38 AC 501 ms
13,440 KB
testcase_39 AC 497 ms
13,568 KB
testcase_40 AC 494 ms
13,408 KB
testcase_41 AC 494 ms
13,440 KB
testcase_42 AC 494 ms
13,400 KB
testcase_43 AC 497 ms
13,400 KB
testcase_44 AC 501 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
int main(){
  int N;
  cin >> N;
  vector<vector<long long>> X(N, vector<long long>(5));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 5; j++){
      cin >> X[i][j];
    }
  }
  vector<long long> ans(N, 0);
  for (int i = 0; i < (1 << 5); i++){
    vector<long long> S(N, 0);
    for (int j = 0; j < N; j++){
      for (int k = 0; k < 5; k++){
        if ((i >> k & 1) == 0){
          S[j] += X[j][k];
        } else {
          S[j] -= X[j][k];
        }
      }
    }
    vector<long long> L(N + 1, INF);
    for (int j = 0; j < N; j++){
      L[j + 1] = min(L[j], S[j]);
    }
    vector<long long> R(N + 1, INF);
    for (int j = N - 1; j >= 0; j--){
      R[j] = min(R[j + 1], S[j]);
    }
    for (int j = 0; j < N; j++){
      ans[j] = max(ans[j], S[j] - min(L[j], R[j + 1]));
    }
  }
  for (int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }
}
0