結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー umezoumezo
提出日時 2021-01-22 22:44:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 484 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 2,532 ms
コンパイル使用メモリ 205,376 KB
実行使用メモリ 9,656 KB
最終ジャッジ日時 2023-08-27 20:56:02
合計ジャッジ時間 30,987 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 242 ms
6,156 KB
testcase_04 AC 242 ms
6,168 KB
testcase_05 AC 228 ms
6,160 KB
testcase_06 AC 228 ms
6,124 KB
testcase_07 AC 337 ms
7,496 KB
testcase_08 AC 337 ms
7,604 KB
testcase_09 AC 93 ms
4,380 KB
testcase_10 AC 93 ms
4,460 KB
testcase_11 AC 427 ms
8,688 KB
testcase_12 AC 427 ms
8,492 KB
testcase_13 AC 276 ms
6,800 KB
testcase_14 AC 278 ms
6,696 KB
testcase_15 AC 239 ms
6,312 KB
testcase_16 AC 239 ms
6,128 KB
testcase_17 AC 452 ms
8,804 KB
testcase_18 AC 454 ms
9,116 KB
testcase_19 AC 394 ms
8,132 KB
testcase_20 AC 391 ms
8,296 KB
testcase_21 AC 423 ms
8,716 KB
testcase_22 AC 422 ms
8,668 KB
testcase_23 AC 291 ms
7,124 KB
testcase_24 AC 292 ms
7,028 KB
testcase_25 AC 46 ms
4,384 KB
testcase_26 AC 46 ms
4,384 KB
testcase_27 AC 151 ms
4,836 KB
testcase_28 AC 150 ms
4,892 KB
testcase_29 AC 185 ms
5,416 KB
testcase_30 AC 185 ms
5,364 KB
testcase_31 AC 247 ms
6,488 KB
testcase_32 AC 247 ms
6,216 KB
testcase_33 AC 182 ms
5,548 KB
testcase_34 AC 183 ms
5,424 KB
testcase_35 AC 241 ms
6,308 KB
testcase_36 AC 241 ms
6,232 KB
testcase_37 AC 49 ms
4,384 KB
testcase_38 AC 49 ms
4,376 KB
testcase_39 AC 40 ms
4,380 KB
testcase_40 AC 40 ms
4,380 KB
testcase_41 AC 87 ms
4,376 KB
testcase_42 AC 86 ms
4,380 KB
testcase_43 AC 70 ms
4,376 KB
testcase_44 AC 450 ms
9,020 KB
testcase_45 AC 189 ms
5,424 KB
testcase_46 AC 65 ms
4,380 KB
testcase_47 AC 318 ms
7,340 KB
testcase_48 AC 304 ms
6,908 KB
testcase_49 AC 309 ms
7,268 KB
testcase_50 AC 237 ms
6,156 KB
testcase_51 AC 13 ms
4,380 KB
testcase_52 AC 403 ms
8,324 KB
testcase_53 AC 467 ms
9,336 KB
testcase_54 AC 477 ms
9,396 KB
testcase_55 AC 473 ms
9,384 KB
testcase_56 AC 478 ms
9,324 KB
testcase_57 AC 484 ms
9,408 KB
testcase_58 AC 478 ms
9,600 KB
testcase_59 AC 475 ms
9,332 KB
testcase_60 AC 471 ms
9,288 KB
testcase_61 AC 457 ms
9,476 KB
testcase_62 AC 476 ms
9,464 KB
testcase_63 AC 479 ms
9,340 KB
testcase_64 AC 478 ms
9,440 KB
testcase_65 AC 473 ms
9,504 KB
testcase_66 AC 473 ms
9,296 KB
testcase_67 AC 483 ms
9,384 KB
testcase_68 AC 469 ms
9,444 KB
testcase_69 AC 454 ms
9,380 KB
testcase_70 AC 458 ms
9,380 KB
testcase_71 AC 451 ms
9,384 KB
testcase_72 AC 478 ms
9,332 KB
testcase_73 AC 471 ms
9,476 KB
testcase_74 AC 468 ms
9,412 KB
testcase_75 AC 470 ms
9,624 KB
testcase_76 AC 466 ms
9,656 KB
testcase_77 AC 470 ms
9,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

ll n,k,MOD;

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x%MOD;
    x=x*x%MOD;
    n/=2;
  }
  return ans;
}

int main(){
  cin>>n>>k>>MOD;
  
  vector<ll> P(n),E(n),A(n),H(n);
  rep(i,n) cin>>P[i];
  rep(i,n) cin>>E[i];
  rep(i,n) cin>>A[i];
  rep(i,n) cin>>H[i];
  
  sort(ALL(P));
  sort(ALL(E));
  sort(ALL(A));
  sort(ALL(H));
  
  ll ans=0;
  rep(i,n){
    ll ma=max({P[i],E[i],A[i],H[i]});
    ll mi=min({P[i],E[i],A[i],H[i]});
    ans=(ans+modpow(ma-mi,k))%MOD;
  }
  cout<<ans<<endl;
  
  return 0;
}
0