結果

問題 No.2261 Coffee
ユーザー risujirohrisujiroh
提出日時 2023-04-07 22:27:57
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 3,571 bytes
コンパイル時間 3,462 ms
コンパイル使用メモリ 281,456 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-10 17:27:17
合計ジャッジ時間 7,901 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,820 KB
testcase_03 AC 2 ms
6,812 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 6 ms
6,944 KB
testcase_18 AC 6 ms
6,944 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 5 ms
6,940 KB
testcase_23 AC 6 ms
6,944 KB
testcase_24 AC 132 ms
6,944 KB
testcase_25 AC 106 ms
6,940 KB
testcase_26 AC 127 ms
7,156 KB
testcase_27 AC 118 ms
6,944 KB
testcase_28 AC 60 ms
6,940 KB
testcase_29 AC 59 ms
6,944 KB
testcase_30 AC 49 ms
6,944 KB
testcase_31 AC 78 ms
7,268 KB
testcase_32 AC 77 ms
7,160 KB
testcase_33 AC 76 ms
7,284 KB
testcase_34 AC 78 ms
7,296 KB
testcase_35 AC 78 ms
7,168 KB
testcase_36 AC 77 ms
7,212 KB
testcase_37 AC 77 ms
7,212 KB
testcase_38 AC 125 ms
7,212 KB
testcase_39 AC 124 ms
7,172 KB
testcase_40 AC 127 ms
7,128 KB
testcase_41 AC 128 ms
7,168 KB
testcase_42 AC 123 ms
7,108 KB
testcase_43 AC 126 ms
7,124 KB
testcase_44 AC 124 ms
7,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define show(...) static_cast<void>(0)
#define all(c) begin(c), end(c)
#define for(...) for ([[maybe_unused]] auto&& __VA_ARGS__)
#define lambda(...) [&](auto&&... args) { return __VA_ARGS__; }
#define $1 get<0>(tie(args...))
#define $2 get<1>(tie(args...))
template <bool = false> struct Rep {
  int l, r, d;
  Rep begin() const;
  int end() const;
  bool operator!=(int) const;
  void operator++();
  int operator*() const;
};
Rep<> rep(int, int, int = 1);
Rep<> rep1(int, int, int = 1);
Rep<true> per(int, int, int = 1);
Rep<true> per1(int, int, int = 1);
template <class R> int len(R&&);
template <class R, class I> int len(R&&, I);
template <class T, class U = T> bool chmin(T&, U&&);
template <class T, class U = T> bool chmax(T&, U&&);
template <class T> ostream& operator<<(ostream&, const vector<T>&);
template <class T> auto operator<<(ostream& os, T&& t) -> decltype(tuple_cat(t), os);
template <class T = int> T input();
template <class... Ts> void print(Ts&&...);

void solve() {
  int n = input();
  vector<array<int64_t, 5>> a(n);
  for (ai : a) {
    for (e : ai) {
      e = input<int64_t>();
    }
  }
  vector<int64_t> v(1 << 5, numeric_limits<int64_t>::lowest());
  for (ai : a) {
    for (mask : rep(0, 1 << 5)) {
      int64_t cur = 0;
      for (j : rep(0, 5)) {
        cur += mask >> j & 1 ? -ai[j] : ai[j];
      }
      chmax(v[mask], cur);
    }
  }
  for (ai : a) {
    int64_t ans = 0;
    for (mask : rep(0, 1 << 5)) {
      int64_t cur = v[mask];
      for (j : rep(0, 5)) {
        cur -= mask >> j & 1 ? -ai[j] : ai[j];
      }
      chmax(ans, cur);
    }
    print(ans);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  solve();
}

template <bool R>
Rep<R> Rep<R>::begin() const {
  return *this;
}

template <bool R>
int Rep<R>::end() const {
  return 0;
}

template <bool R>
bool Rep<R>::operator!=(int) const {
  return l <= r;
}

template <bool R>
void Rep<R>::operator++() {
  if constexpr (R) {
    r -= d;
  } else {
    l += d;
  }
}

template <bool R>
int Rep<R>::operator*() const {
  if constexpr (R) {
    return r;
  } else {
    return l;
  }
}

inline Rep<> rep(int l, int r, int d) {
  assert(0 < d);
  return {l, r - 1, d};
}

inline Rep<> rep1(int l, int r, int d) {
  assert(0 < d);
  return {l, r, d};
}

inline Rep<true> per(int l, int r, int d) {
  assert(0 < d);
  assert((r - l) % d == 0);
  return {l, r - d, d};
}

inline Rep<true> per1(int l, int r, int d) {
  assert(0 < d);
  return {l, r, d};
}

template <class R>
int len(R&& r) {
  return static_cast<int>(size(forward<R>(r)));
}

template <class R, class I>
int len(R&& r, I i) {
  return static_cast<int>(distance(begin(forward<R>(r)), i));
}

template <class T, class U>
bool chmin(T& x, U&& y) {
  return y < x && (x = forward<U>(y), true);
}

template <class T, class U>
bool chmax(T& x, U&& y) {
  return x < y && (x = forward<U>(y), true);
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  auto sep = "";
  for (e : v) {
    os << exchange(sep, " ") << e;
  }
  return os;
}

template <class T>
auto operator<<(ostream& os, T&& t) -> decltype(tuple_cat(t), os) {
  auto f = [&](auto&&... args) -> ostream& {
    [[maybe_unused]] auto sep = "";
    (..., (os << exchange(sep, " ") << forward<decltype(args)>(args)));
    return os;
  };
  return apply(f, forward<T>(t));
}

template <class T>
T input() {
  T x;
  cin >> x;
  return x;
}

template <class... Ts>
void print(Ts&&... xs) {
  cout << forward_as_tuple(forward<Ts>(xs)...) << '\n';
}
0