結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 Kazun
提出日時 2020-09-24 22:35:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,358 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 77,864 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-25 16:37:37
合計ジャッジ時間 28,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 75
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

int unfairness(int p, int e, int a, int h) {
	int max = p;
	if (max < e) max = e;
	if (max < a) max = a;
	if (max < h) max = h;

	int min = p;
	if (min > e) min = e;
	if (min > a) min = a;
	if (min > h) min = h;

	return max - min;
}

int main() {
	int N;
	ll ans=0;

	cin >> N;

	vector<int> P(N), E(N), A(N), H(N);

	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	sort(P.begin(), P.end());

	for (int i = 0; i < N; i++) {
		cin >> E.at(i);
	}
	sort(E.begin(), E.end());

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());

	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}
	sort(H.begin(), H.end());

	for (int i = 0; i < N; i++) {
		ans += unfairness(P.at(i), E.at(i), A.at(i), H.at(i));
	}

	cout << ans << endl;

	for (int i = 0; i < N; i++) {
		cout << P.at(i);
		if (i < N - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << E.at(i);
		if (i < N - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << A.at(i);
		if (i < N - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << H.at(i);
		if (i < N - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	return 0;
}
0