結果

問題 No.2261 Coffee
ユーザー kabipoyokabipoyo
提出日時 2023-04-07 23:41:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 440 ms / 2,000 ms
コード長 1,340 bytes
コンパイル時間 4,091 ms
コンパイル使用メモリ 258,076 KB
実行使用メモリ 12,112 KB
最終ジャッジ日時 2024-04-10 18:17:56
合計ジャッジ時間 13,861 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 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,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 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,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 14 ms
6,944 KB
testcase_18 AC 13 ms
6,940 KB
testcase_19 AC 13 ms
6,944 KB
testcase_20 AC 11 ms
6,940 KB
testcase_21 AC 14 ms
6,944 KB
testcase_22 AC 11 ms
6,940 KB
testcase_23 AC 14 ms
6,944 KB
testcase_24 AC 439 ms
11,300 KB
testcase_25 AC 358 ms
10,112 KB
testcase_26 AC 440 ms
11,920 KB
testcase_27 AC 378 ms
11,136 KB
testcase_28 AC 187 ms
10,700 KB
testcase_29 AC 183 ms
10,292 KB
testcase_30 AC 145 ms
8,832 KB
testcase_31 AC 254 ms
11,852 KB
testcase_32 AC 234 ms
11,856 KB
testcase_33 AC 236 ms
11,856 KB
testcase_34 AC 245 ms
11,860 KB
testcase_35 AC 243 ms
11,984 KB
testcase_36 AC 240 ms
11,856 KB
testcase_37 AC 240 ms
11,856 KB
testcase_38 AC 413 ms
11,856 KB
testcase_39 AC 417 ms
12,112 KB
testcase_40 AC 423 ms
11,856 KB
testcase_41 AC 437 ms
11,980 KB
testcase_42 AC 424 ms
11,860 KB
testcase_43 AC 437 ms
11,984 KB
testcase_44 AC 413 ms
11,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(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; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint N;
	cin >> N;
	vvi v(N, vi(5));
	rep(i, N) vin(v[i]);

	lint a=0, b=0, c=0, x, y, z;
	vi ans(N);
	rep(bits, 1<<5) {
		vi t(N);
		a = -LINF;
		b = LINF;
		rep(i, N) {
			rep(j, 5) {
				if ((bits & (1<<j)) != 0) {
					t[i] += v[i][j];
				} else {
					t[i] -= v[i][j];
				}
			}
			chmax(a, t[i]);
			chmin(b, t[i]);
		}
		rep(i, N) {
			ans[i] = max({ans[i], t[i]-b, a-t[i]});
		}
	}
	rep(i, N) cout << ans[i] << endl;
}
0