結果

問題 No.2261 Coffee
ユーザー startcppstartcpp
提出日時 2023-04-15 17:33:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 430 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 66,568 KB
実行使用メモリ 20,096 KB
最終ジャッジ日時 2024-04-19 10:57:21
合計ジャッジ時間 11,706 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 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 14 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 14 ms
5,376 KB
testcase_22 AC 11 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 389 ms
18,688 KB
testcase_25 AC 337 ms
16,768 KB
testcase_26 AC 407 ms
19,840 KB
testcase_27 AC 381 ms
18,560 KB
testcase_28 AC 200 ms
17,408 KB
testcase_29 AC 188 ms
17,152 KB
testcase_30 AC 150 ms
14,080 KB
testcase_31 AC 245 ms
19,968 KB
testcase_32 AC 238 ms
19,968 KB
testcase_33 AC 248 ms
19,840 KB
testcase_34 AC 234 ms
19,968 KB
testcase_35 AC 246 ms
19,840 KB
testcase_36 AC 233 ms
19,840 KB
testcase_37 AC 232 ms
19,968 KB
testcase_38 AC 412 ms
20,096 KB
testcase_39 AC 430 ms
19,968 KB
testcase_40 AC 406 ms
19,932 KB
testcase_41 AC 411 ms
19,840 KB
testcase_42 AC 408 ms
19,968 KB
testcase_43 AC 406 ms
19,840 KB
testcase_44 AC 408 ms
19,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[100000][5];
int b[100000][1 << 4];
int maxB[1 << 4];
int minB[1 << 4];

signed main() {
	int i, j, k;
	int d = 5;

	cin >> n;
	rep(i, n) rep(j, d) cin >> a[i][j];
	
	int INF = 1e+18;
	rep(i, (1 << (d - 1))) {
		maxB[i] = -INF;
		minB[i] = INF;
	}

	rep(i, n) {
		rep(j, (1 << (d - 1))) { //j次元目の座標
			int val = a[i][0];
			rep(k, d - 1) {
				if ((j >> k) % 2 == 1) val += a[i][k + 1];
				else val -= a[i][k + 1];
			}
			b[i][j] = val;
			maxB[j] = max(maxB[j], b[i][j]);
			minB[j] = min(minB[j], b[i][j]);
		}
	}

	rep(i, n) {
		int ans = 0;
		rep(j, (1 << (d - 1))) {
			int score1 = maxB[j] - b[i][j];
			int score2 = b[i][j] - minB[j];
			ans = max(ans, score1);
			ans = max(ans, score2);
		}
		cout << ans << endl;
	}
	return 0;
}
0