結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー ShibuyapShibuyap
提出日時 2021-02-06 07:56:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 990 bytes
コンパイル時間 3,761 ms
コンパイル使用メモリ 202,688 KB
実行使用メモリ 9,792 KB
最終ジャッジ日時 2023-09-15 12:37:49
合計ジャッジ時間 35,635 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 243 ms
6,456 KB
testcase_04 AC 242 ms
6,560 KB
testcase_05 AC 227 ms
6,700 KB
testcase_06 AC 226 ms
6,400 KB
testcase_07 AC 333 ms
7,836 KB
testcase_08 AC 332 ms
8,036 KB
testcase_09 AC 93 ms
4,488 KB
testcase_10 AC 92 ms
4,484 KB
testcase_11 AC 423 ms
8,992 KB
testcase_12 AC 423 ms
8,860 KB
testcase_13 AC 274 ms
7,024 KB
testcase_14 AC 272 ms
6,964 KB
testcase_15 AC 238 ms
6,560 KB
testcase_16 AC 239 ms
6,408 KB
testcase_17 AC 449 ms
9,128 KB
testcase_18 AC 447 ms
9,132 KB
testcase_19 AC 390 ms
8,388 KB
testcase_20 AC 388 ms
8,492 KB
testcase_21 AC 503 ms
8,784 KB
testcase_22 AC 420 ms
8,732 KB
testcase_23 AC 289 ms
7,288 KB
testcase_24 AC 290 ms
7,352 KB
testcase_25 AC 46 ms
4,380 KB
testcase_26 AC 46 ms
4,380 KB
testcase_27 AC 150 ms
5,204 KB
testcase_28 AC 150 ms
5,488 KB
testcase_29 AC 183 ms
5,672 KB
testcase_30 AC 183 ms
5,712 KB
testcase_31 AC 245 ms
6,492 KB
testcase_32 AC 246 ms
6,600 KB
testcase_33 AC 180 ms
5,648 KB
testcase_34 AC 182 ms
5,652 KB
testcase_35 AC 240 ms
6,500 KB
testcase_36 AC 239 ms
6,488 KB
testcase_37 AC 49 ms
4,380 KB
testcase_38 AC 49 ms
4,380 KB
testcase_39 AC 40 ms
4,376 KB
testcase_40 AC 40 ms
4,380 KB
testcase_41 AC 86 ms
4,392 KB
testcase_42 AC 86 ms
4,520 KB
testcase_43 AC 69 ms
4,376 KB
testcase_44 AC 447 ms
9,272 KB
testcase_45 AC 189 ms
5,708 KB
testcase_46 AC 65 ms
4,380 KB
testcase_47 AC 315 ms
7,404 KB
testcase_48 AC 302 ms
7,400 KB
testcase_49 AC 306 ms
7,636 KB
testcase_50 AC 234 ms
6,428 KB
testcase_51 AC 12 ms
4,380 KB
testcase_52 AC 400 ms
8,532 KB
testcase_53 AC 461 ms
9,528 KB
testcase_54 AC 474 ms
9,572 KB
testcase_55 AC 469 ms
9,580 KB
testcase_56 AC 474 ms
9,696 KB
testcase_57 AC 476 ms
9,496 KB
testcase_58 AC 475 ms
9,764 KB
testcase_59 AC 471 ms
9,540 KB
testcase_60 AC 467 ms
9,572 KB
testcase_61 AC 454 ms
9,528 KB
testcase_62 AC 471 ms
9,540 KB
testcase_63 AC 472 ms
9,632 KB
testcase_64 AC 473 ms
9,540 KB
testcase_65 AC 470 ms
9,524 KB
testcase_66 AC 470 ms
9,564 KB
testcase_67 AC 478 ms
9,588 KB
testcase_68 AC 466 ms
9,496 KB
testcase_69 AC 450 ms
9,536 KB
testcase_70 AC 452 ms
9,568 KB
testcase_71 AC 443 ms
9,524 KB
testcase_72 AC 475 ms
9,692 KB
testcase_73 AC 468 ms
9,536 KB
testcase_74 AC 466 ms
9,588 KB
testcase_75 AC 467 ms
9,792 KB
testcase_76 AC 463 ms
9,488 KB
testcase_77 AC 465 ms
9,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, k, m;
    cin >> n >> k >> m;
    ll a[n], b[n], c[n], d[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    rep(i,n) cin >> d[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    sort(d,d+n);
    ll ans = 0;
    rep(i,n){
        ll ma = max(max(a[i],b[i]),max(c[i],d[i]));
        ll mi = min(min(a[i],b[i]),min(c[i],d[i]));
        ans += mod_pow(ma-mi, k, m);
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}
 
 
0