結果

問題 No.2261 Coffee
ユーザー zawakasuzawakasu
提出日時 2023-04-07 21:58:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 694 ms / 2,000 ms
コード長 3,378 bytes
コンパイル時間 2,465 ms
コンパイル使用メモリ 207,992 KB
実行使用メモリ 12,008 KB
最終ジャッジ日時 2024-04-10 17:04:05
合計ジャッジ時間 17,343 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 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 17 ms
6,944 KB
testcase_18 AC 17 ms
6,944 KB
testcase_19 AC 16 ms
6,940 KB
testcase_20 AC 13 ms
6,944 KB
testcase_21 AC 18 ms
6,944 KB
testcase_22 AC 15 ms
6,940 KB
testcase_23 AC 19 ms
6,944 KB
testcase_24 AC 619 ms
11,324 KB
testcase_25 AC 519 ms
10,240 KB
testcase_26 AC 667 ms
11,688 KB
testcase_27 AC 602 ms
11,244 KB
testcase_28 AC 447 ms
10,464 KB
testcase_29 AC 436 ms
10,316 KB
testcase_30 AC 339 ms
8,704 KB
testcase_31 AC 551 ms
11,880 KB
testcase_32 AC 553 ms
11,876 KB
testcase_33 AC 543 ms
11,880 KB
testcase_34 AC 544 ms
11,884 KB
testcase_35 AC 535 ms
11,884 KB
testcase_36 AC 536 ms
11,884 KB
testcase_37 AC 551 ms
11,880 KB
testcase_38 AC 657 ms
11,876 KB
testcase_39 AC 687 ms
11,880 KB
testcase_40 AC 693 ms
11,876 KB
testcase_41 AC 673 ms
12,008 KB
testcase_42 AC 694 ms
11,884 KB
testcase_43 AC 663 ms
12,008 KB
testcase_44 AC 657 ms
11,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define all(x) begin(x), end(x)
#define times(x) for (int _ = 0 ; _ < (int)(x) ; _++)

using i32 = int;
using i64 = long long;
using ld = long double;
using usize = std::size_t;

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b and (a = b, true); }
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b and (a = b, true); }

constexpr i64 supl = (std::numeric_limits<i64>::max() >> 1) - 100;
constexpr i32 supi = (std::numeric_limits<i32>::max() >> 1) - 100;



namespace zawa::input {

template <typename T> 
void in(T& res) { std::cin >> res; }

template <typename Head, typename... Tail>
void in(Head& head, Tail&... tail) { in(head); in(tail...); }

template <typename T, typename U>
void in(std::pair<T, U>& res) { in(res.first); in(res.second); }

template <typename T>
void in(std::vector<T>& res) { for (auto& r : res) { in(r); } }

} // namespace zawa::input
using zawa::input::in;



namespace zawa::output {

void out() { 
    std::cout << std::endl; 
}

template <class T>
void out(const T& a) { 
    std::cout << a << std::endl; 
}

template <class T>
void out(const std::vector<T>& as) { 
    for (std::size_t i = 0 ; i < as.size() ; i++) { 
        std::cout << as[i] << (i + 1 == as.size() ? '\n' : ' '); 
    } 
}

template <class Head, class... Tail>
void out(const Head& head, const Tail&... tail) { 
    std::cout << head; 
    if (sizeof...(tail)) { 
        std::cout << ' '; 
    } 
    out(tail...);
}

void yesno(bool flag, std::string yes = "Yes", std::string no = "No") {
    std::cout << (flag ? yes : no) << std::endl;
}

} // namespace zawa::output
using zawa::output::out;
using zawa::output::yesno;



namespace zawa::util {

template <class T>
std::vector<T> sorted(std::vector<T> A) {
	std::sort(A.begin(), A.end());
	return A;
}

std::string sorted(std::string s) {
	std::sort(s.begin(), s.end());
	return s;
}

} // namespace zawa::util


namespace zawa::util {

template <class T>
std::vector<T> reversed(std::vector<T> A) {
	std::reverse(A.begin(), A.end());
	return A;
}

std::string reversed(std::string s) {
	std::reverse(s.begin(), s.end());
	return s;
}

} // namespace zawa::util
using namespace zawa::util;

// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
// using mint = atcoder::modint1000000007;

// #include "src/template/accum1d.hpp"
// #include "src/template/binary-search.hpp"
// #include "src/template/binary-search-ld.hpp"
// #include "src/algorithm/compression.hpp"
// #include "src/algorithm/RLE.hpp"

// #include "src/graph/Read-Graph.hpp"
// #include "src/graph/Read-Weighted-Graph.hpp"

using namespace std;

void main_() {
	i32 n; in(n);
	vector A(n, vector(5, 0LL));
	for (i32 i = 0 ; i < n ; i++) for (auto& a : A[i]) in(a);
	auto get = [](vector<i64> a, i32 bit) -> i64 {
		i64 res = 0LL;
		for (i32 i = 0 ; i < 5 ; i++) res += (bit & (1 << i) ? 1LL : -1LL) * a[i];
		return res;
	};
	vector ans(n, -supl);
	for (i32 bit = 0 ; bit < (1 << 5) ; bit++) {
		vector B(n, 0LL);
		for (i32 i = 0 ; i < n ; i++) B[i] = get(A[i], bit);
		sort(all(B));
		for (i32 i = 0 ; i < n ; i++) chmax(ans[i], max(B[n - 1] - get(A[i], bit), get(A[i], bit) - B[0]));
	}
	for (auto a : ans) out(a);
}

i32 main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);

	main_();

	return 0;
}
0