結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tnakao0123tnakao0123
提出日時 2021-01-25 15:16:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 1,246 bytes
コンパイル時間 1,213 ms
コンパイル使用メモリ 94,124 KB
実行使用メモリ 6,900 KB
最終ジャッジ日時 2023-09-04 06:31:58
合計ジャッジ時間 21,843 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 146 ms
5,096 KB
testcase_04 AC 146 ms
5,148 KB
testcase_05 AC 133 ms
5,228 KB
testcase_06 AC 133 ms
5,100 KB
testcase_07 AC 199 ms
5,720 KB
testcase_08 AC 200 ms
5,780 KB
testcase_09 AC 56 ms
4,376 KB
testcase_10 AC 56 ms
4,376 KB
testcase_11 AC 258 ms
6,328 KB
testcase_12 AC 258 ms
6,484 KB
testcase_13 AC 165 ms
5,396 KB
testcase_14 AC 165 ms
5,336 KB
testcase_15 AC 145 ms
5,236 KB
testcase_16 AC 145 ms
5,088 KB
testcase_17 AC 274 ms
6,408 KB
testcase_18 AC 274 ms
6,484 KB
testcase_19 AC 237 ms
6,136 KB
testcase_20 AC 236 ms
6,008 KB
testcase_21 AC 256 ms
6,312 KB
testcase_22 AC 256 ms
6,420 KB
testcase_23 AC 173 ms
5,476 KB
testcase_24 AC 173 ms
5,744 KB
testcase_25 AC 27 ms
4,384 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 90 ms
4,476 KB
testcase_28 AC 91 ms
4,488 KB
testcase_29 AC 112 ms
4,860 KB
testcase_30 AC 110 ms
4,696 KB
testcase_31 AC 148 ms
5,308 KB
testcase_32 AC 148 ms
5,184 KB
testcase_33 AC 110 ms
4,784 KB
testcase_34 AC 109 ms
4,716 KB
testcase_35 AC 145 ms
5,368 KB
testcase_36 AC 144 ms
5,080 KB
testcase_37 AC 29 ms
4,380 KB
testcase_38 AC 30 ms
4,376 KB
testcase_39 AC 24 ms
4,376 KB
testcase_40 AC 24 ms
4,376 KB
testcase_41 AC 52 ms
4,380 KB
testcase_42 AC 52 ms
4,376 KB
testcase_43 AC 41 ms
4,376 KB
testcase_44 AC 272 ms
6,480 KB
testcase_45 AC 114 ms
4,696 KB
testcase_46 AC 39 ms
4,380 KB
testcase_47 AC 193 ms
5,604 KB
testcase_48 AC 180 ms
5,548 KB
testcase_49 AC 182 ms
5,564 KB
testcase_50 AC 141 ms
5,224 KB
testcase_51 AC 8 ms
4,376 KB
testcase_52 AC 242 ms
6,208 KB
testcase_53 AC 274 ms
6,764 KB
testcase_54 AC 287 ms
6,760 KB
testcase_55 AC 283 ms
6,676 KB
testcase_56 AC 289 ms
6,596 KB
testcase_57 AC 291 ms
6,616 KB
testcase_58 AC 287 ms
6,692 KB
testcase_59 AC 286 ms
6,664 KB
testcase_60 AC 280 ms
6,668 KB
testcase_61 AC 267 ms
6,788 KB
testcase_62 AC 286 ms
6,900 KB
testcase_63 AC 286 ms
6,600 KB
testcase_64 AC 288 ms
6,604 KB
testcase_65 AC 284 ms
6,788 KB
testcase_66 AC 284 ms
6,612 KB
testcase_67 AC 291 ms
6,616 KB
testcase_68 AC 280 ms
6,564 KB
testcase_69 AC 265 ms
6,628 KB
testcase_70 AC 265 ms
6,760 KB
testcase_71 AC 257 ms
6,628 KB
testcase_72 AC 290 ms
6,564 KB
testcase_73 AC 282 ms
6,640 KB
testcase_74 AC 278 ms
6,628 KB
testcase_75 AC 280 ms
6,636 KB
testcase_76 AC 277 ms
6,624 KB
testcase_77 AC 280 ms
6,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1359.cc:  No.1359 [Zelkova 3rd Tune] 四人セゾン - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int L = 4;

/* typedef */

typedef long long ll;

/* global variables */

int as[L][MAX_N];

/* subroutines */

inline int powmod(int a, int n, int mod) {  // a^n % mod
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % mod;
    a = (ll)a * a % mod;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);

  for (int i = 0; i < L; i++) {
    for (int j = 0; j < n; j++) scanf("%d", as[i] + j);
    sort(as[i], as[i] + n);
  }

  int sum = 0;
  for (int j = 0; j < n; j++) {
    int mina = as[0][j], maxa = as[0][j];
    for (int i = 1; i < L; i++)
      mina = min(mina, as[i][j]), maxa = max(maxa, as[i][j]);

    sum = (sum + powmod(maxa - mina, k, m)) % m;
  }

  printf("%d\n", sum);
  return 0;
}
0