結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー vkgainzvkgainz
提出日時 2021-06-12 08:01:59
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 543 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 131,904 KB
実行使用メモリ 7,212 KB
最終ジャッジ日時 2023-08-22 04:10:27
合計ジャッジ時間 39,546 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 273 ms
5,228 KB
testcase_04 AC 272 ms
5,232 KB
testcase_05 AC 255 ms
5,244 KB
testcase_06 AC 256 ms
5,284 KB
testcase_07 AC 371 ms
6,008 KB
testcase_08 AC 372 ms
6,036 KB
testcase_09 AC 106 ms
4,376 KB
testcase_10 AC 105 ms
4,380 KB
testcase_11 AC 472 ms
6,496 KB
testcase_12 AC 473 ms
6,536 KB
testcase_13 AC 302 ms
5,484 KB
testcase_14 AC 305 ms
5,520 KB
testcase_15 AC 271 ms
5,092 KB
testcase_16 AC 271 ms
4,964 KB
testcase_17 AC 511 ms
6,816 KB
testcase_18 AC 514 ms
6,784 KB
testcase_19 AC 441 ms
6,396 KB
testcase_20 AC 444 ms
6,236 KB
testcase_21 AC 477 ms
6,544 KB
testcase_22 AC 476 ms
6,516 KB
testcase_23 AC 319 ms
5,480 KB
testcase_24 AC 319 ms
5,484 KB
testcase_25 AC 50 ms
4,380 KB
testcase_26 AC 50 ms
4,380 KB
testcase_27 AC 168 ms
4,492 KB
testcase_28 AC 167 ms
4,416 KB
testcase_29 AC 206 ms
4,676 KB
testcase_30 AC 205 ms
4,764 KB
testcase_31 AC 275 ms
5,236 KB
testcase_32 AC 274 ms
5,276 KB
testcase_33 AC 203 ms
4,684 KB
testcase_34 AC 202 ms
4,700 KB
testcase_35 AC 270 ms
5,236 KB
testcase_36 AC 268 ms
5,208 KB
testcase_37 AC 55 ms
4,380 KB
testcase_38 AC 54 ms
4,380 KB
testcase_39 AC 45 ms
4,380 KB
testcase_40 AC 45 ms
4,380 KB
testcase_41 AC 94 ms
4,380 KB
testcase_42 AC 94 ms
4,376 KB
testcase_43 AC 77 ms
4,376 KB
testcase_44 AC 493 ms
6,852 KB
testcase_45 AC 213 ms
4,752 KB
testcase_46 AC 72 ms
4,380 KB
testcase_47 AC 364 ms
5,744 KB
testcase_48 AC 330 ms
5,728 KB
testcase_49 AC 336 ms
5,796 KB
testcase_50 AC 264 ms
5,264 KB
testcase_51 AC 13 ms
4,380 KB
testcase_52 AC 448 ms
6,496 KB
testcase_53 AC 512 ms
7,048 KB
testcase_54 AC 537 ms
7,112 KB
testcase_55 AC 530 ms
7,048 KB
testcase_56 AC 532 ms
7,048 KB
testcase_57 AC 536 ms
7,132 KB
testcase_58 AC 535 ms
7,028 KB
testcase_59 AC 525 ms
7,072 KB
testcase_60 AC 516 ms
7,072 KB
testcase_61 AC 501 ms
7,076 KB
testcase_62 AC 527 ms
7,212 KB
testcase_63 AC 527 ms
7,048 KB
testcase_64 AC 535 ms
7,060 KB
testcase_65 AC 530 ms
7,080 KB
testcase_66 AC 521 ms
7,060 KB
testcase_67 AC 543 ms
7,060 KB
testcase_68 AC 521 ms
7,140 KB
testcase_69 AC 489 ms
7,052 KB
testcase_70 AC 495 ms
7,020 KB
testcase_71 AC 486 ms
7,124 KB
testcase_72 AC 540 ms
7,060 KB
testcase_73 AC 474 ms
7,032 KB
testcase_74 AC 476 ms
7,032 KB
testcase_75 AC 476 ms
7,028 KB
testcase_76 AC 470 ms
7,048 KB
testcase_77 AC 470 ms
7,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long power(long long b, int p, long long M) {
    if(p == 0) return 1LL;
    long long x = power(b, p / 2, M);
    x = x * x % M;
    if(p % 2) x = x * b % M;
    return x;
}

int main() {
    int N, K, M; cin >> N >> K >> M;
    vector<int> P(N), E(N), A(N), H(N);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> E[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(P.begin(), P.end());
    sort(E.begin(), E.end());
    sort(A.begin(), A.end());
    sort(H.begin(), H.end());
    vector<int> D(N);
    for(int i = 0; i < N; i++) {
        int mx = 0, mn = 1000000000;
        mx = max({P[i], E[i], A[i], H[i]});
        mn = min({P[i], E[i], A[i], H[i]});
        D[i] = (mx - mn);
    }
    long long ans = 0LL;
    for(int i = 0; i < N; i++) {
        ans += power(D[i], K, M);
        ans %= M;
    }
    if(ans < 0) ans += M;
    cout << ans;
}
0