結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 KazunKazun
提出日時 2020-12-27 20:25:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 75,320 KB
実行使用メモリ 6,324 KB
最終ジャッジ日時 2023-08-26 17:31:38
合計ジャッジ時間 28,586 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,004 KB
testcase_01 AC 1 ms
4,944 KB
testcase_02 AC 1 ms
4,948 KB
testcase_03 AC 220 ms
5,004 KB
testcase_04 AC 216 ms
4,940 KB
testcase_05 AC 209 ms
4,944 KB
testcase_06 AC 209 ms
4,944 KB
testcase_07 AC 301 ms
5,356 KB
testcase_08 AC 299 ms
5,404 KB
testcase_09 AC 82 ms
4,944 KB
testcase_10 AC 84 ms
5,008 KB
testcase_11 AC 391 ms
5,912 KB
testcase_12 AC 405 ms
5,888 KB
testcase_13 AC 250 ms
5,004 KB
testcase_14 AC 247 ms
5,000 KB
testcase_15 AC 216 ms
4,944 KB
testcase_16 AC 215 ms
4,948 KB
testcase_17 AC 413 ms
5,888 KB
testcase_18 AC 425 ms
5,888 KB
testcase_19 AC 360 ms
5,696 KB
testcase_20 AC 366 ms
5,636 KB
testcase_21 AC 381 ms
5,760 KB
testcase_22 AC 388 ms
5,672 KB
testcase_23 AC 266 ms
5,004 KB
testcase_24 AC 264 ms
5,008 KB
testcase_25 AC 42 ms
4,944 KB
testcase_26 AC 41 ms
4,944 KB
testcase_27 AC 135 ms
5,012 KB
testcase_28 AC 139 ms
4,944 KB
testcase_29 AC 166 ms
4,952 KB
testcase_30 AC 168 ms
4,948 KB
testcase_31 AC 225 ms
4,944 KB
testcase_32 AC 220 ms
4,944 KB
testcase_33 AC 167 ms
4,944 KB
testcase_34 AC 172 ms
4,940 KB
testcase_35 AC 223 ms
4,948 KB
testcase_36 AC 229 ms
4,944 KB
testcase_37 AC 47 ms
4,944 KB
testcase_38 AC 46 ms
5,008 KB
testcase_39 AC 37 ms
5,008 KB
testcase_40 AC 36 ms
5,008 KB
testcase_41 AC 77 ms
4,944 KB
testcase_42 AC 81 ms
4,944 KB
testcase_43 AC 64 ms
4,944 KB
testcase_44 AC 423 ms
5,936 KB
testcase_45 AC 166 ms
5,012 KB
testcase_46 AC 59 ms
4,944 KB
testcase_47 AC 284 ms
5,192 KB
testcase_48 AC 274 ms
5,144 KB
testcase_49 AC 292 ms
5,116 KB
testcase_50 AC 218 ms
4,944 KB
testcase_51 AC 11 ms
4,948 KB
testcase_52 AC 374 ms
5,636 KB
testcase_53 AC 427 ms
6,228 KB
testcase_54 AC 445 ms
6,164 KB
testcase_55 AC 432 ms
6,288 KB
testcase_56 AC 421 ms
6,200 KB
testcase_57 AC 435 ms
6,208 KB
testcase_58 AC 435 ms
6,176 KB
testcase_59 AC 435 ms
6,204 KB
testcase_60 AC 432 ms
6,200 KB
testcase_61 AC 420 ms
6,180 KB
testcase_62 AC 436 ms
6,148 KB
testcase_63 AC 431 ms
6,180 KB
testcase_64 AC 440 ms
6,204 KB
testcase_65 AC 422 ms
6,160 KB
testcase_66 AC 430 ms
6,324 KB
testcase_67 AC 433 ms
6,160 KB
testcase_68 AC 419 ms
6,256 KB
testcase_69 AC 416 ms
6,160 KB
testcase_70 AC 411 ms
6,228 KB
testcase_71 AC 405 ms
6,320 KB
testcase_72 AC 439 ms
6,256 KB
testcase_73 AC 425 ms
6,272 KB
testcase_74 AC 428 ms
6,216 KB
testcase_75 AC 424 ms
6,164 KB
testcase_76 AC 421 ms
6,204 KB
testcase_77 AC 431 ms
6,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using ll = long long;

int power_mod(int a,int n,int 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;
}

int max(vector<int> X){
	int r=X[0];
	for (auto x:X) if (r<x) r=x;
	return r;
}

int min(vector<int> X){
	int r=X[0];
	for (auto x:X) if (r>x) r=x;
	return r;
}

ll unfairness(int p, int e, int a, int h){
	return max({p,e,a,h})-min({p,e,a,h});
}

void vector_input(vector<int>& X){
	for(int i=0;i<X.size();i++){
		cin >> X[i];
	}
	sort(X.begin(),X.end());
}
int main(){
	int N,K,M;
	cin >> N >> K >> M;

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

	vector_input(P);
	vector_input(E);
	vector_input(A);
	vector_input(H);

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