結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー SSRSSSRS
提出日時 2021-01-22 21:39:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 171,216 KB
実行使用メモリ 7,240 KB
最終ジャッジ日時 2023-08-27 18:09:58
合計ジャッジ時間 30,905 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,944 KB
testcase_01 AC 2 ms
5,012 KB
testcase_02 AC 2 ms
4,952 KB
testcase_03 AC 238 ms
5,012 KB
testcase_04 AC 237 ms
5,412 KB
testcase_05 AC 224 ms
5,016 KB
testcase_06 AC 223 ms
5,016 KB
testcase_07 AC 328 ms
6,004 KB
testcase_08 AC 328 ms
5,872 KB
testcase_09 AC 90 ms
4,948 KB
testcase_10 AC 91 ms
4,944 KB
testcase_11 AC 417 ms
6,392 KB
testcase_12 AC 416 ms
6,528 KB
testcase_13 AC 269 ms
5,344 KB
testcase_14 AC 269 ms
5,700 KB
testcase_15 AC 235 ms
5,076 KB
testcase_16 AC 235 ms
5,016 KB
testcase_17 AC 441 ms
6,764 KB
testcase_18 AC 441 ms
6,788 KB
testcase_19 AC 384 ms
6,220 KB
testcase_20 AC 382 ms
6,200 KB
testcase_21 AC 414 ms
6,488 KB
testcase_22 AC 412 ms
6,464 KB
testcase_23 AC 285 ms
5,408 KB
testcase_24 AC 285 ms
5,468 KB
testcase_25 AC 45 ms
4,948 KB
testcase_26 AC 45 ms
5,008 KB
testcase_27 AC 147 ms
4,956 KB
testcase_28 AC 147 ms
5,012 KB
testcase_29 AC 181 ms
5,012 KB
testcase_30 AC 180 ms
5,012 KB
testcase_31 AC 241 ms
5,076 KB
testcase_32 AC 241 ms
5,076 KB
testcase_33 AC 178 ms
4,948 KB
testcase_34 AC 178 ms
5,008 KB
testcase_35 AC 235 ms
5,144 KB
testcase_36 AC 237 ms
4,948 KB
testcase_37 AC 48 ms
5,016 KB
testcase_38 AC 48 ms
4,944 KB
testcase_39 AC 39 ms
4,952 KB
testcase_40 AC 39 ms
4,948 KB
testcase_41 AC 84 ms
4,952 KB
testcase_42 AC 84 ms
4,952 KB
testcase_43 AC 68 ms
5,008 KB
testcase_44 AC 439 ms
6,804 KB
testcase_45 AC 185 ms
4,952 KB
testcase_46 AC 63 ms
4,948 KB
testcase_47 AC 310 ms
5,744 KB
testcase_48 AC 297 ms
5,776 KB
testcase_49 AC 301 ms
5,612 KB
testcase_50 AC 230 ms
5,172 KB
testcase_51 AC 12 ms
4,948 KB
testcase_52 AC 394 ms
6,484 KB
testcase_53 AC 452 ms
7,028 KB
testcase_54 AC 468 ms
6,968 KB
testcase_55 AC 463 ms
6,972 KB
testcase_56 AC 465 ms
7,240 KB
testcase_57 AC 468 ms
6,992 KB
testcase_58 AC 467 ms
7,100 KB
testcase_59 AC 465 ms
7,016 KB
testcase_60 AC 459 ms
7,012 KB
testcase_61 AC 447 ms
6,924 KB
testcase_62 AC 463 ms
6,932 KB
testcase_63 AC 465 ms
7,100 KB
testcase_64 AC 467 ms
7,024 KB
testcase_65 AC 463 ms
7,060 KB
testcase_66 AC 465 ms
6,928 KB
testcase_67 AC 471 ms
6,936 KB
testcase_68 AC 460 ms
7,008 KB
testcase_69 AC 445 ms
6,932 KB
testcase_70 AC 444 ms
7,108 KB
testcase_71 AC 436 ms
7,056 KB
testcase_72 AC 471 ms
7,024 KB
testcase_73 AC 460 ms
6,924 KB
testcase_74 AC 456 ms
7,088 KB
testcase_75 AC 459 ms
6,920 KB
testcase_76 AC 456 ms
6,976 KB
testcase_77 AC 457 ms
6,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b, long long MOD){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
int main(){
  int N, K, M;
  cin >> N >> K >> M;
  vector<vector<int>> A(4, vector<int>(N));
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < N; j++){
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < 4; i++){
    sort(A[i].begin(), A[i].end());
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    int X = max({A[0][i], A[1][i], A[2][i], A[3][i]});
    int Y = min({A[0][i], A[1][i], A[2][i], A[3][i]});
    ans += modpow(X - Y, K, M);
    ans %= M;
  }
  cout << ans << endl;
}
0