結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー HaaHaa
提出日時 2021-01-22 21:24:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 506 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 2,483 ms
コンパイル使用メモリ 171,656 KB
実行使用メモリ 11,268 KB
最終ジャッジ日時 2023-08-27 17:11:22
合計ジャッジ時間 32,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,948 KB
testcase_01 AC 2 ms
4,948 KB
testcase_02 AC 2 ms
4,948 KB
testcase_03 AC 267 ms
7,132 KB
testcase_04 AC 244 ms
6,948 KB
testcase_05 AC 231 ms
7,072 KB
testcase_06 AC 255 ms
6,924 KB
testcase_07 AC 340 ms
8,724 KB
testcase_08 AC 354 ms
8,544 KB
testcase_09 AC 93 ms
4,952 KB
testcase_10 AC 93 ms
4,952 KB
testcase_11 AC 429 ms
9,860 KB
testcase_12 AC 431 ms
10,244 KB
testcase_13 AC 276 ms
7,532 KB
testcase_14 AC 277 ms
7,812 KB
testcase_15 AC 240 ms
6,920 KB
testcase_16 AC 240 ms
7,044 KB
testcase_17 AC 455 ms
10,408 KB
testcase_18 AC 456 ms
10,572 KB
testcase_19 AC 394 ms
9,464 KB
testcase_20 AC 395 ms
9,300 KB
testcase_21 AC 506 ms
9,976 KB
testcase_22 AC 427 ms
9,824 KB
testcase_23 AC 294 ms
7,756 KB
testcase_24 AC 295 ms
7,796 KB
testcase_25 AC 48 ms
4,960 KB
testcase_26 AC 46 ms
4,952 KB
testcase_27 AC 151 ms
5,364 KB
testcase_28 AC 182 ms
5,380 KB
testcase_29 AC 189 ms
6,032 KB
testcase_30 AC 191 ms
5,892 KB
testcase_31 AC 253 ms
7,312 KB
testcase_32 AC 248 ms
6,956 KB
testcase_33 AC 184 ms
5,928 KB
testcase_34 AC 184 ms
6,080 KB
testcase_35 AC 245 ms
7,004 KB
testcase_36 AC 242 ms
7,004 KB
testcase_37 AC 54 ms
4,956 KB
testcase_38 AC 49 ms
4,952 KB
testcase_39 AC 43 ms
4,960 KB
testcase_40 AC 40 ms
4,952 KB
testcase_41 AC 133 ms
4,952 KB
testcase_42 AC 88 ms
5,016 KB
testcase_43 AC 83 ms
4,948 KB
testcase_44 AC 480 ms
10,384 KB
testcase_45 AC 195 ms
6,276 KB
testcase_46 AC 65 ms
4,952 KB
testcase_47 AC 323 ms
8,100 KB
testcase_48 AC 324 ms
8,008 KB
testcase_49 AC 314 ms
8,392 KB
testcase_50 AC 238 ms
6,960 KB
testcase_51 AC 14 ms
4,956 KB
testcase_52 AC 405 ms
9,748 KB
testcase_53 AC 469 ms
11,268 KB
testcase_54 AC 479 ms
11,036 KB
testcase_55 AC 478 ms
11,104 KB
testcase_56 AC 478 ms
11,120 KB
testcase_57 AC 484 ms
10,960 KB
testcase_58 AC 480 ms
11,092 KB
testcase_59 AC 480 ms
11,008 KB
testcase_60 AC 473 ms
11,008 KB
testcase_61 AC 459 ms
10,892 KB
testcase_62 AC 482 ms
11,036 KB
testcase_63 AC 478 ms
11,216 KB
testcase_64 AC 481 ms
10,884 KB
testcase_65 AC 477 ms
11,032 KB
testcase_66 AC 475 ms
10,908 KB
testcase_67 AC 488 ms
11,096 KB
testcase_68 AC 472 ms
11,072 KB
testcase_69 AC 458 ms
11,068 KB
testcase_70 AC 460 ms
11,032 KB
testcase_71 AC 451 ms
11,032 KB
testcase_72 AC 480 ms
11,240 KB
testcase_73 AC 473 ms
10,924 KB
testcase_74 AC 470 ms
11,068 KB
testcase_75 AC 474 ms
11,104 KB
testcase_76 AC 469 ms
11,008 KB
testcase_77 AC 470 ms
10,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;

ll power(ll x, ll y, ll m){
    x%=m;
    ll ret=1;
    while(y){
        if(y&1) ret=ret*x%m;
        x=x*x%m;
        y>>=1;
    }
    return ret;
}

int main(){
    int n, k, m; cin >> n >> k >> m;
    VVI a(4,VI(n));
    REP(i,4)REP(j,n) cin >> a[i][j];
    REP(i,4) sort(ALL(a[i]));
    ll ans=0;
    REP(i,n){
        ll mx=0, mn=INF;
        REP(j,4){
            mx=max(mx,a[j][i]);
            mn=min(mn,a[j][i]);
        }
        ans+=power(mx-mn,k,m);
        ans%=m;
    }
    cout << ans << endl;
    return 0;
}
0