結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 KazunKazun
提出日時 2020-12-27 21:42:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 76,384 KB
実行使用メモリ 6,364 KB
最終ジャッジ日時 2023-08-26 17:32:48
合計ジャッジ時間 29,617 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 236 ms
4,580 KB
testcase_04 AC 237 ms
4,560 KB
testcase_05 AC 224 ms
4,608 KB
testcase_06 AC 223 ms
4,584 KB
testcase_07 AC 328 ms
5,308 KB
testcase_08 AC 330 ms
5,312 KB
testcase_09 AC 91 ms
4,376 KB
testcase_10 AC 91 ms
4,384 KB
testcase_11 AC 417 ms
5,832 KB
testcase_12 AC 418 ms
5,888 KB
testcase_13 AC 268 ms
4,828 KB
testcase_14 AC 269 ms
4,816 KB
testcase_15 AC 234 ms
4,604 KB
testcase_16 AC 234 ms
4,632 KB
testcase_17 AC 441 ms
5,896 KB
testcase_18 AC 439 ms
6,128 KB
testcase_19 AC 383 ms
5,636 KB
testcase_20 AC 383 ms
5,664 KB
testcase_21 AC 411 ms
5,628 KB
testcase_22 AC 411 ms
5,628 KB
testcase_23 AC 285 ms
4,836 KB
testcase_24 AC 284 ms
4,776 KB
testcase_25 AC 45 ms
4,376 KB
testcase_26 AC 45 ms
4,380 KB
testcase_27 AC 147 ms
4,380 KB
testcase_28 AC 147 ms
4,376 KB
testcase_29 AC 181 ms
4,380 KB
testcase_30 AC 179 ms
4,384 KB
testcase_31 AC 241 ms
4,520 KB
testcase_32 AC 241 ms
4,580 KB
testcase_33 AC 178 ms
4,380 KB
testcase_34 AC 179 ms
4,380 KB
testcase_35 AC 236 ms
4,568 KB
testcase_36 AC 236 ms
4,580 KB
testcase_37 AC 47 ms
4,376 KB
testcase_38 AC 48 ms
4,380 KB
testcase_39 AC 39 ms
4,384 KB
testcase_40 AC 39 ms
4,380 KB
testcase_41 AC 85 ms
4,376 KB
testcase_42 AC 84 ms
4,376 KB
testcase_43 AC 69 ms
4,376 KB
testcase_44 AC 441 ms
5,832 KB
testcase_45 AC 186 ms
4,380 KB
testcase_46 AC 63 ms
4,380 KB
testcase_47 AC 312 ms
5,092 KB
testcase_48 AC 298 ms
5,080 KB
testcase_49 AC 302 ms
5,112 KB
testcase_50 AC 230 ms
4,520 KB
testcase_51 AC 12 ms
4,376 KB
testcase_52 AC 395 ms
5,640 KB
testcase_53 AC 452 ms
6,164 KB
testcase_54 AC 466 ms
6,160 KB
testcase_55 AC 463 ms
6,100 KB
testcase_56 AC 464 ms
6,152 KB
testcase_57 AC 467 ms
6,260 KB
testcase_58 AC 469 ms
6,152 KB
testcase_59 AC 467 ms
6,164 KB
testcase_60 AC 460 ms
6,100 KB
testcase_61 AC 446 ms
6,364 KB
testcase_62 AC 466 ms
6,100 KB
testcase_63 AC 465 ms
6,180 KB
testcase_64 AC 469 ms
6,156 KB
testcase_65 AC 462 ms
6,100 KB
testcase_66 AC 464 ms
6,148 KB
testcase_67 AC 469 ms
6,104 KB
testcase_68 AC 458 ms
6,100 KB
testcase_69 AC 443 ms
6,132 KB
testcase_70 AC 444 ms
6,100 KB
testcase_71 AC 435 ms
6,168 KB
testcase_72 AC 467 ms
6,088 KB
testcase_73 AC 460 ms
6,212 KB
testcase_74 AC 457 ms
6,188 KB
testcase_75 AC 459 ms
6,108 KB
testcase_76 AC 457 ms
6,096 KB
testcase_77 AC 457 ms
6,136 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;

	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.at(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.at(i),E.at(i),A.at(i),H.at(i));
		X+=power_mod(y,K,M);
		X%=M;
	}
	cout << X << endl;
}
0