結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー zuminzumin
提出日時 2021-02-24 22:59:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 691 ms / 2,000 ms
コード長 1,002 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 78,756 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2023-10-25 04:23:08
合計ジャッジ時間 47,663 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 316 ms
7,240 KB
testcase_04 AC 316 ms
7,240 KB
testcase_05 AC 300 ms
7,224 KB
testcase_06 AC 297 ms
7,224 KB
testcase_07 AC 440 ms
9,744 KB
testcase_08 AC 447 ms
9,744 KB
testcase_09 AC 118 ms
4,944 KB
testcase_10 AC 118 ms
4,944 KB
testcase_11 AC 575 ms
10,552 KB
testcase_12 AC 569 ms
10,552 KB
testcase_13 AC 358 ms
7,472 KB
testcase_14 AC 356 ms
7,472 KB
testcase_15 AC 318 ms
7,208 KB
testcase_16 AC 314 ms
7,208 KB
testcase_17 AC 619 ms
10,672 KB
testcase_18 AC 612 ms
10,672 KB
testcase_19 AC 529 ms
10,304 KB
testcase_20 AC 526 ms
10,304 KB
testcase_21 AC 571 ms
10,496 KB
testcase_22 AC 573 ms
10,496 KB
testcase_23 AC 374 ms
7,872 KB
testcase_24 AC 378 ms
7,872 KB
testcase_25 AC 57 ms
4,348 KB
testcase_26 AC 56 ms
4,348 KB
testcase_27 AC 192 ms
5,592 KB
testcase_28 AC 192 ms
5,592 KB
testcase_29 AC 238 ms
6,600 KB
testcase_30 AC 237 ms
6,600 KB
testcase_31 AC 319 ms
7,288 KB
testcase_32 AC 321 ms
7,288 KB
testcase_33 AC 235 ms
6,584 KB
testcase_34 AC 237 ms
6,584 KB
testcase_35 AC 312 ms
7,240 KB
testcase_36 AC 316 ms
7,240 KB
testcase_37 AC 61 ms
4,348 KB
testcase_38 AC 61 ms
4,348 KB
testcase_39 AC 50 ms
4,348 KB
testcase_40 AC 50 ms
4,348 KB
testcase_41 AC 107 ms
4,912 KB
testcase_42 AC 107 ms
4,912 KB
testcase_43 AC 87 ms
4,416 KB
testcase_44 AC 593 ms
10,728 KB
testcase_45 AC 246 ms
6,624 KB
testcase_46 AC 82 ms
4,364 KB
testcase_47 AC 431 ms
9,544 KB
testcase_48 AC 389 ms
7,944 KB
testcase_49 AC 397 ms
9,560 KB
testcase_50 AC 309 ms
7,224 KB
testcase_51 AC 15 ms
4,348 KB
testcase_52 AC 532 ms
10,400 KB
testcase_53 AC 614 ms
11,136 KB
testcase_54 AC 643 ms
11,136 KB
testcase_55 AC 638 ms
11,136 KB
testcase_56 AC 643 ms
11,136 KB
testcase_57 AC 657 ms
11,136 KB
testcase_58 AC 644 ms
11,136 KB
testcase_59 AC 637 ms
11,136 KB
testcase_60 AC 641 ms
11,136 KB
testcase_61 AC 628 ms
11,136 KB
testcase_62 AC 660 ms
11,136 KB
testcase_63 AC 691 ms
11,136 KB
testcase_64 AC 666 ms
11,136 KB
testcase_65 AC 656 ms
11,136 KB
testcase_66 AC 646 ms
11,136 KB
testcase_67 AC 664 ms
11,136 KB
testcase_68 AC 631 ms
11,136 KB
testcase_69 AC 591 ms
11,136 KB
testcase_70 AC 597 ms
11,136 KB
testcase_71 AC 589 ms
11,136 KB
testcase_72 AC 648 ms
11,136 KB
testcase_73 AC 626 ms
11,136 KB
testcase_74 AC 621 ms
11,136 KB
testcase_75 AC 622 ms
11,136 KB
testcase_76 AC 618 ms
11,136 KB
testcase_77 AC 620 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
using ll=long long;

ll powmod(ll base,ll exp,ll mod){
    ll cnt=0;
    ll texp=exp;
    while(texp){cnt++;texp/=2;}
    vector<ll> dp(cnt,0);
    dp[0]=base%mod;
    for(ll i=1;i<cnt;i++){
        dp[i]=(dp[i-1]*dp[i-1])%mod;
    }
    ll ans=1;
    for(ll i=0;i<cnt;i++){
        if((exp>>i)&1){
            ans*=dp[i];
            ans%=mod;
        }
    }
    return ans;
}
int main(){
    ll n,k,m;
    cin>>n>>k>>m;
    vector<priority_queue<ll>> q(4);
    ll ans=0;

    for(int i=0;i<4;i++){
        for(int j=0;j<n;j++){
            ll tmp;
            cin>>tmp;
            q[i].push(tmp);
        }
    }

    for(int i=0;i<n;i++){
        ll ma=0,mi=1000000000;
        for(int j=0;j<4;j++){
            ll tmp=q[j].top();q[j].pop();
            ma=max(ma,tmp);
            mi=min(mi,tmp);
        }
        ans+=powmod(ma-mi,k,m);
        ans%=m;
    }
    cout<<ans<<endl;

    return 0;
}
0