結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー kappybarkappybar
提出日時 2021-01-22 21:55:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 487 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 2,630 ms
コンパイル使用メモリ 170,684 KB
実行使用メモリ 9,652 KB
最終ジャッジ日時 2023-08-27 18:47:47
合計ジャッジ時間 32,166 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 247 ms
6,224 KB
testcase_04 AC 244 ms
6,160 KB
testcase_05 AC 232 ms
6,216 KB
testcase_06 AC 235 ms
6,196 KB
testcase_07 AC 341 ms
7,464 KB
testcase_08 AC 346 ms
7,476 KB
testcase_09 AC 93 ms
4,440 KB
testcase_10 AC 94 ms
4,504 KB
testcase_11 AC 430 ms
8,596 KB
testcase_12 AC 430 ms
8,652 KB
testcase_13 AC 276 ms
6,676 KB
testcase_14 AC 277 ms
6,676 KB
testcase_15 AC 244 ms
6,280 KB
testcase_16 AC 241 ms
6,148 KB
testcase_17 AC 456 ms
8,984 KB
testcase_18 AC 457 ms
8,784 KB
testcase_19 AC 394 ms
8,320 KB
testcase_20 AC 398 ms
8,060 KB
testcase_21 AC 427 ms
8,576 KB
testcase_22 AC 426 ms
8,588 KB
testcase_23 AC 295 ms
7,024 KB
testcase_24 AC 296 ms
6,952 KB
testcase_25 AC 48 ms
4,380 KB
testcase_26 AC 46 ms
4,380 KB
testcase_27 AC 151 ms
4,892 KB
testcase_28 AC 154 ms
4,960 KB
testcase_29 AC 185 ms
5,364 KB
testcase_30 AC 188 ms
5,424 KB
testcase_31 AC 250 ms
6,216 KB
testcase_32 AC 249 ms
6,276 KB
testcase_33 AC 185 ms
5,364 KB
testcase_34 AC 184 ms
5,488 KB
testcase_35 AC 245 ms
6,152 KB
testcase_36 AC 244 ms
6,284 KB
testcase_37 AC 50 ms
4,384 KB
testcase_38 AC 49 ms
4,380 KB
testcase_39 AC 40 ms
4,384 KB
testcase_40 AC 40 ms
4,380 KB
testcase_41 AC 89 ms
4,384 KB
testcase_42 AC 87 ms
4,384 KB
testcase_43 AC 71 ms
4,380 KB
testcase_44 AC 458 ms
9,068 KB
testcase_45 AC 192 ms
5,424 KB
testcase_46 AC 65 ms
4,380 KB
testcase_47 AC 322 ms
7,284 KB
testcase_48 AC 309 ms
6,988 KB
testcase_49 AC 313 ms
7,200 KB
testcase_50 AC 239 ms
6,204 KB
testcase_51 AC 13 ms
4,388 KB
testcase_52 AC 406 ms
8,388 KB
testcase_53 AC 470 ms
9,308 KB
testcase_54 AC 483 ms
9,396 KB
testcase_55 AC 481 ms
9,652 KB
testcase_56 AC 481 ms
9,452 KB
testcase_57 AC 485 ms
9,316 KB
testcase_58 AC 483 ms
9,456 KB
testcase_59 AC 481 ms
9,376 KB
testcase_60 AC 477 ms
9,368 KB
testcase_61 AC 464 ms
9,328 KB
testcase_62 AC 480 ms
9,384 KB
testcase_63 AC 480 ms
9,312 KB
testcase_64 AC 483 ms
9,648 KB
testcase_65 AC 479 ms
9,384 KB
testcase_66 AC 479 ms
9,392 KB
testcase_67 AC 487 ms
9,448 KB
testcase_68 AC 473 ms
9,312 KB
testcase_69 AC 461 ms
9,324 KB
testcase_70 AC 459 ms
9,400 KB
testcase_71 AC 452 ms
9,316 KB
testcase_72 AC 483 ms
9,444 KB
testcase_73 AC 477 ms
9,356 KB
testcase_74 AC 473 ms
9,308 KB
testcase_75 AC 475 ms
9,376 KB
testcase_76 AC 473 ms
9,376 KB
testcase_77 AC 473 ms
9,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y));
#define chmax(x,y) x = max((x),(y));
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

long long modpow(long long x, long long n,long long m) {
    long long ret = 1;
    x %= m;
    while (n > 0) {
        if (n & 1) ret = (ret * x) % m;  
        x = (x * x) % m;
        n >>= 1; 
    }
    return ret;
}

vector<ll> a[4];

int main(){
    ll n,k,m;
    cin >> n >> k >> m;
    rep(i,4) a[i].resize(n);
    rep(i,4)rep(j,n) cin >> a[i][j];
    rep(i,4) sort(a[i].begin(),a[i].end());
    ll ans = 0;
    rep(i,n){
        ll mn = LINF;
        ll mx = -LINF;
        rep(j,4){
            chmin(mn,a[j][i]);
            chmax(mx,a[j][i]);
        }
        ans += modpow(mx-mn,k,m);
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}
0