結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー rogi52rogi52
提出日時 2022-10-03 20:46:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 205,812 KB
実行使用メモリ 7,172 KB
最終ジャッジ日時 2023-08-27 18:57:40
合計ジャッジ時間 21,602 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 142 ms
5,168 KB
testcase_04 AC 142 ms
5,120 KB
testcase_05 AC 128 ms
4,800 KB
testcase_06 AC 128 ms
5,164 KB
testcase_07 AC 193 ms
6,016 KB
testcase_08 AC 193 ms
5,964 KB
testcase_09 AC 54 ms
4,376 KB
testcase_10 AC 54 ms
4,380 KB
testcase_11 AC 248 ms
6,560 KB
testcase_12 AC 248 ms
6,544 KB
testcase_13 AC 159 ms
5,384 KB
testcase_14 AC 159 ms
5,332 KB
testcase_15 AC 141 ms
4,968 KB
testcase_16 AC 140 ms
4,852 KB
testcase_17 AC 265 ms
6,660 KB
testcase_18 AC 265 ms
6,756 KB
testcase_19 AC 229 ms
6,224 KB
testcase_20 AC 231 ms
6,128 KB
testcase_21 AC 249 ms
6,392 KB
testcase_22 AC 248 ms
6,384 KB
testcase_23 AC 168 ms
5,480 KB
testcase_24 AC 167 ms
5,372 KB
testcase_25 AC 27 ms
4,376 KB
testcase_26 AC 27 ms
4,380 KB
testcase_27 AC 88 ms
4,388 KB
testcase_28 AC 88 ms
4,424 KB
testcase_29 AC 107 ms
4,588 KB
testcase_30 AC 107 ms
4,548 KB
testcase_31 AC 144 ms
5,296 KB
testcase_32 AC 143 ms
5,060 KB
testcase_33 AC 106 ms
4,588 KB
testcase_34 AC 106 ms
4,636 KB
testcase_35 AC 140 ms
5,292 KB
testcase_36 AC 140 ms
5,156 KB
testcase_37 AC 29 ms
4,376 KB
testcase_38 AC 29 ms
4,380 KB
testcase_39 AC 23 ms
4,376 KB
testcase_40 AC 23 ms
4,376 KB
testcase_41 AC 50 ms
4,380 KB
testcase_42 AC 50 ms
4,380 KB
testcase_43 AC 41 ms
4,376 KB
testcase_44 AC 262 ms
6,708 KB
testcase_45 AC 110 ms
4,644 KB
testcase_46 AC 38 ms
4,376 KB
testcase_47 AC 188 ms
5,752 KB
testcase_48 AC 176 ms
5,748 KB
testcase_49 AC 177 ms
5,596 KB
testcase_50 AC 136 ms
4,852 KB
testcase_51 AC 7 ms
4,376 KB
testcase_52 AC 235 ms
6,432 KB
testcase_53 AC 266 ms
7,020 KB
testcase_54 AC 279 ms
7,084 KB
testcase_55 AC 279 ms
7,016 KB
testcase_56 AC 279 ms
6,968 KB
testcase_57 AC 281 ms
7,000 KB
testcase_58 AC 280 ms
7,004 KB
testcase_59 AC 277 ms
7,060 KB
testcase_60 AC 272 ms
7,172 KB
testcase_61 AC 259 ms
7,064 KB
testcase_62 AC 277 ms
7,056 KB
testcase_63 AC 278 ms
7,012 KB
testcase_64 AC 280 ms
7,020 KB
testcase_65 AC 275 ms
7,020 KB
testcase_66 AC 276 ms
6,912 KB
testcase_67 AC 284 ms
7,016 KB
testcase_68 AC 271 ms
7,084 KB
testcase_69 AC 256 ms
6,968 KB
testcase_70 AC 258 ms
7,072 KB
testcase_71 AC 249 ms
7,068 KB
testcase_72 AC 282 ms
6,972 KB
testcase_73 AC 273 ms
7,000 KB
testcase_74 AC 270 ms
6,912 KB
testcase_75 AC 271 ms
7,016 KB
testcase_76 AC 269 ms
7,072 KB
testcase_77 AC 270 ms
7,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll modpow(ll a,ll b,ll mod){
    ll ans = 1;
    a %= mod;
    while(b){
        if(b&1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,K,M; cin >> N >> K >> M;
    vector<vector<int>> A(4, vector<int>(N));
    rep(k,4) {
        rep(i,N) cin >> A[k][i];
        sort(A[k].begin(), A[k].end());
    }

    ll ans = 0;
    rep(i,N) {
        vector<int> G(4);
        rep(k,4) G[k] = A[k][i];
        int ma = *max_element(G.begin(), G.end());
        int mi = *min_element(G.begin(), G.end());
        ans += modpow(ma - mi, K, M);
        ans %= M;
    }
    cout << ans << endl;
}
0