結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー DriceDrice
提出日時 2021-01-22 21:47:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 45,172 KB
実行使用メモリ 9,284 KB
最終ジャッジ日時 2023-08-27 18:35:29
合計ジャッジ時間 20,560 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,068 KB
testcase_01 AC 2 ms
7,084 KB
testcase_02 AC 3 ms
7,016 KB
testcase_03 AC 143 ms
8,328 KB
testcase_04 AC 144 ms
8,400 KB
testcase_05 AC 130 ms
8,340 KB
testcase_06 AC 131 ms
8,264 KB
testcase_07 AC 196 ms
8,728 KB
testcase_08 AC 196 ms
8,600 KB
testcase_09 AC 56 ms
7,676 KB
testcase_10 AC 56 ms
7,612 KB
testcase_11 AC 252 ms
8,940 KB
testcase_12 AC 251 ms
9,000 KB
testcase_13 AC 161 ms
8,508 KB
testcase_14 AC 162 ms
8,464 KB
testcase_15 AC 144 ms
8,248 KB
testcase_16 AC 143 ms
8,376 KB
testcase_17 AC 268 ms
9,012 KB
testcase_18 AC 268 ms
9,016 KB
testcase_19 AC 233 ms
8,812 KB
testcase_20 AC 232 ms
8,764 KB
testcase_21 AC 251 ms
8,916 KB
testcase_22 AC 251 ms
8,980 KB
testcase_23 AC 170 ms
8,468 KB
testcase_24 AC 169 ms
8,512 KB
testcase_25 AC 28 ms
7,404 KB
testcase_26 AC 28 ms
7,356 KB
testcase_27 AC 89 ms
7,960 KB
testcase_28 AC 90 ms
8,048 KB
testcase_29 AC 109 ms
8,184 KB
testcase_30 AC 109 ms
8,092 KB
testcase_31 AC 145 ms
8,428 KB
testcase_32 AC 146 ms
8,404 KB
testcase_33 AC 108 ms
8,200 KB
testcase_34 AC 109 ms
8,152 KB
testcase_35 AC 142 ms
8,328 KB
testcase_36 AC 141 ms
8,400 KB
testcase_37 AC 30 ms
7,376 KB
testcase_38 AC 30 ms
7,432 KB
testcase_39 AC 25 ms
7,332 KB
testcase_40 AC 24 ms
7,336 KB
testcase_41 AC 52 ms
7,708 KB
testcase_42 AC 51 ms
7,628 KB
testcase_43 AC 41 ms
7,524 KB
testcase_44 AC 263 ms
9,128 KB
testcase_45 AC 112 ms
8,164 KB
testcase_46 AC 39 ms
7,476 KB
testcase_47 AC 189 ms
8,560 KB
testcase_48 AC 177 ms
8,504 KB
testcase_49 AC 178 ms
8,572 KB
testcase_50 AC 138 ms
8,260 KB
testcase_51 AC 8 ms
7,148 KB
testcase_52 AC 236 ms
8,928 KB
testcase_53 AC 268 ms
9,280 KB
testcase_54 AC 283 ms
9,228 KB
testcase_55 AC 279 ms
9,224 KB
testcase_56 AC 283 ms
9,204 KB
testcase_57 AC 286 ms
9,236 KB
testcase_58 AC 283 ms
9,212 KB
testcase_59 AC 282 ms
9,224 KB
testcase_60 AC 274 ms
9,268 KB
testcase_61 AC 262 ms
9,224 KB
testcase_62 AC 279 ms
9,280 KB
testcase_63 AC 281 ms
9,216 KB
testcase_64 AC 283 ms
9,208 KB
testcase_65 AC 281 ms
9,208 KB
testcase_66 AC 279 ms
9,284 KB
testcase_67 AC 287 ms
9,268 KB
testcase_68 AC 275 ms
9,228 KB
testcase_69 AC 258 ms
9,272 KB
testcase_70 AC 260 ms
9,272 KB
testcase_71 AC 251 ms
9,208 KB
testcase_72 AC 283 ms
9,268 KB
testcase_73 AC 278 ms
9,212 KB
testcase_74 AC 275 ms
9,212 KB
testcase_75 AC 276 ms
9,284 KB
testcase_76 AC 274 ms
9,280 KB
testcase_77 AC 275 ms
9,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
long long mod = -1;

long long power(long long a,long long b){
    long long res = 1;
    while(b){
        if(b%2) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long a[4][200005];

int main(){
    int n,k;
    scanf("%d%d%lld",&n,&k,&mod);
    for(int i = 0; i < 4; i++){
        for(int j = 1; j <= n; j++) scanf("%lld",&a[i][j]);
        std::sort(a[i]+1,a[i]+1+n);
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        long long minn = a[0][i], maxn = a[0][i];
        for(int j = 1; j < 4; j++){
            if(minn>a[j][i]) minn = a[j][i];
            if(maxn<a[j][i]) maxn = a[j][i]; 
        }
        ans += power(maxn-minn,k);
        if(ans >= mod) ans -= mod;
    }
    printf("%lld\n",ans);
    return 0;
}
0