結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 KazunKazun
提出日時 2020-12-27 17:18:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 977 bytes
コンパイル時間 2,564 ms
コンパイル使用メモリ 74,644 KB
実行使用メモリ 9,412 KB
最終ジャッジ日時 2023-08-26 17:29:37
合計ジャッジ時間 31,329 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 247 ms
6,172 KB
testcase_04 AC 245 ms
6,172 KB
testcase_05 AC 231 ms
6,188 KB
testcase_06 AC 231 ms
6,252 KB
testcase_07 AC 340 ms
7,492 KB
testcase_08 AC 340 ms
7,516 KB
testcase_09 AC 94 ms
4,380 KB
testcase_10 AC 93 ms
4,380 KB
testcase_11 AC 438 ms
8,616 KB
testcase_12 AC 432 ms
8,592 KB
testcase_13 AC 278 ms
6,768 KB
testcase_14 AC 278 ms
6,656 KB
testcase_15 AC 241 ms
6,180 KB
testcase_16 AC 242 ms
6,164 KB
testcase_17 AC 455 ms
8,868 KB
testcase_18 AC 455 ms
8,804 KB
testcase_19 AC 395 ms
8,044 KB
testcase_20 AC 396 ms
8,252 KB
testcase_21 AC 427 ms
8,552 KB
testcase_22 AC 426 ms
8,540 KB
testcase_23 AC 294 ms
6,968 KB
testcase_24 AC 294 ms
6,984 KB
testcase_25 AC 47 ms
4,376 KB
testcase_26 AC 46 ms
4,380 KB
testcase_27 AC 152 ms
5,180 KB
testcase_28 AC 151 ms
4,816 KB
testcase_29 AC 186 ms
5,348 KB
testcase_30 AC 186 ms
5,448 KB
testcase_31 AC 249 ms
6,184 KB
testcase_32 AC 248 ms
6,220 KB
testcase_33 AC 183 ms
5,440 KB
testcase_34 AC 184 ms
5,336 KB
testcase_35 AC 244 ms
6,144 KB
testcase_36 AC 243 ms
6,232 KB
testcase_37 AC 49 ms
4,380 KB
testcase_38 AC 50 ms
4,384 KB
testcase_39 AC 41 ms
4,376 KB
testcase_40 AC 40 ms
4,380 KB
testcase_41 AC 87 ms
4,380 KB
testcase_42 AC 87 ms
4,500 KB
testcase_43 AC 71 ms
4,376 KB
testcase_44 AC 457 ms
9,308 KB
testcase_45 AC 190 ms
5,384 KB
testcase_46 AC 64 ms
4,376 KB
testcase_47 AC 321 ms
7,268 KB
testcase_48 AC 306 ms
6,948 KB
testcase_49 AC 311 ms
7,468 KB
testcase_50 AC 237 ms
6,212 KB
testcase_51 AC 13 ms
4,380 KB
testcase_52 AC 406 ms
8,324 KB
testcase_53 AC 469 ms
9,332 KB
testcase_54 AC 481 ms
9,368 KB
testcase_55 AC 478 ms
9,392 KB
testcase_56 AC 483 ms
9,392 KB
testcase_57 AC 485 ms
9,360 KB
testcase_58 AC 482 ms
9,408 KB
testcase_59 AC 481 ms
9,328 KB
testcase_60 AC 477 ms
9,336 KB
testcase_61 AC 463 ms
9,380 KB
testcase_62 AC 480 ms
9,360 KB
testcase_63 AC 484 ms
9,328 KB
testcase_64 AC 481 ms
9,388 KB
testcase_65 AC 478 ms
9,392 KB
testcase_66 AC 480 ms
9,312 KB
testcase_67 AC 486 ms
9,312 KB
testcase_68 AC 474 ms
9,348 KB
testcase_69 AC 459 ms
9,340 KB
testcase_70 AC 459 ms
9,336 KB
testcase_71 AC 453 ms
9,332 KB
testcase_72 AC 482 ms
9,292 KB
testcase_73 AC 476 ms
9,396 KB
testcase_74 AC 474 ms
9,364 KB
testcase_75 AC 476 ms
9,412 KB
testcase_76 AC 471 ms
9,384 KB
testcase_77 AC 472 ms
9,364 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 - x;

	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);
	}
	sort(X.begin(), X.end());
}

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

	cin >> N >> K >> M;

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

	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