結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 KazunKazun
提出日時 2020-12-27 17:05:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 1,063 bytes
コンパイル時間 1,036 ms
コンパイル使用メモリ 74,848 KB
実行使用メモリ 9,620 KB
最終ジャッジ日時 2023-08-26 17:29:04
合計ジャッジ時間 28,066 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 223 ms
6,272 KB
testcase_04 AC 232 ms
6,340 KB
testcase_05 AC 213 ms
6,160 KB
testcase_06 AC 215 ms
6,156 KB
testcase_07 AC 315 ms
7,628 KB
testcase_08 AC 318 ms
7,636 KB
testcase_09 AC 83 ms
4,600 KB
testcase_10 AC 84 ms
4,384 KB
testcase_11 AC 388 ms
8,568 KB
testcase_12 AC 391 ms
8,680 KB
testcase_13 AC 248 ms
6,768 KB
testcase_14 AC 253 ms
6,684 KB
testcase_15 AC 219 ms
6,476 KB
testcase_16 AC 221 ms
6,160 KB
testcase_17 AC 415 ms
8,836 KB
testcase_18 AC 416 ms
9,088 KB
testcase_19 AC 370 ms
8,004 KB
testcase_20 AC 363 ms
8,004 KB
testcase_21 AC 388 ms
8,580 KB
testcase_22 AC 416 ms
8,632 KB
testcase_23 AC 282 ms
7,048 KB
testcase_24 AC 275 ms
7,236 KB
testcase_25 AC 41 ms
4,384 KB
testcase_26 AC 42 ms
4,384 KB
testcase_27 AC 136 ms
5,220 KB
testcase_28 AC 134 ms
5,256 KB
testcase_29 AC 166 ms
5,460 KB
testcase_30 AC 167 ms
5,408 KB
testcase_31 AC 222 ms
6,196 KB
testcase_32 AC 227 ms
6,264 KB
testcase_33 AC 163 ms
5,360 KB
testcase_34 AC 168 ms
5,404 KB
testcase_35 AC 227 ms
6,156 KB
testcase_36 AC 223 ms
6,448 KB
testcase_37 AC 49 ms
4,384 KB
testcase_38 AC 44 ms
4,384 KB
testcase_39 AC 36 ms
4,380 KB
testcase_40 AC 35 ms
4,380 KB
testcase_41 AC 78 ms
4,384 KB
testcase_42 AC 81 ms
4,384 KB
testcase_43 AC 66 ms
4,380 KB
testcase_44 AC 423 ms
9,144 KB
testcase_45 AC 176 ms
5,364 KB
testcase_46 AC 60 ms
4,388 KB
testcase_47 AC 289 ms
7,316 KB
testcase_48 AC 272 ms
7,104 KB
testcase_49 AC 283 ms
7,260 KB
testcase_50 AC 217 ms
6,456 KB
testcase_51 AC 12 ms
4,384 KB
testcase_52 AC 383 ms
8,368 KB
testcase_53 AC 427 ms
9,368 KB
testcase_54 AC 437 ms
9,324 KB
testcase_55 AC 438 ms
9,320 KB
testcase_56 AC 440 ms
9,528 KB
testcase_57 AC 435 ms
9,432 KB
testcase_58 AC 447 ms
9,328 KB
testcase_59 AC 436 ms
9,432 KB
testcase_60 AC 432 ms
9,484 KB
testcase_61 AC 423 ms
9,408 KB
testcase_62 AC 440 ms
9,456 KB
testcase_63 AC 446 ms
9,420 KB
testcase_64 AC 445 ms
9,364 KB
testcase_65 AC 442 ms
9,372 KB
testcase_66 AC 437 ms
9,376 KB
testcase_67 AC 432 ms
9,484 KB
testcase_68 AC 423 ms
9,372 KB
testcase_69 AC 410 ms
9,424 KB
testcase_70 AC 420 ms
9,484 KB
testcase_71 AC 402 ms
9,432 KB
testcase_72 AC 438 ms
9,620 KB
testcase_73 AC 427 ms
9,440 KB
testcase_74 AC 430 ms
9,504 KB
testcase_75 AC 429 ms
9,484 KB
testcase_76 AC 413 ms
9,480 KB
testcase_77 AC 422 ms
9,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using ll = long long;

ll power_mod(ll a,ll n,ll m) {
	ll ans = 1;
	ll x = a % m;
	if (x<0){
		x += m;
	}

	while (n > 0) {
		if (n % 2 == 1) {
			ans = (ans * x) % m;
		}
		x = (x * x) % m;
		n /= 2;
	}
	return ans;
}


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

	ll min = p;
	if (min > e) min = e;
	if (min > a) min = a;
	if (min > h) min = h;
	
	return power_mod(max - min, k, m);
}

void vector_input(vector<ll>& X) {
	for (int i = 0; i < X.size(); i++) {
		cin >> X.at(i);
	}
}

int main() {
	int N, K, M;

	cin >> N >> K >> M;

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

	vector_input(P);
	sort(P.begin(), P.end());

	vector_input(E);
	sort(E.begin(), E.end());

	vector_input(A);
	sort(A.begin(), A.end());

	vector_input(H);
	sort(H.begin(), H.end());

	ll X = 0;
	for (int i = 0; i < N; i++) {
		X += unfairness(P[i], E[i], A[i], H[i], K, M);
		X %= M;
	}
	cout << X << endl;
	return 0;
}
0