結果

問題 No.1470 Mex Sum
ユーザー MZKiMZKi
提出日時 2021-04-09 21:35:39
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,354 bytes
コンパイル時間 1,323 ms
コンパイル使用メモリ 145,688 KB
実行使用メモリ 9,148 KB
最終ジャッジ日時 2023-09-07 10:14:22
合計ジャッジ時間 20,835 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,148 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1,445 ms
4,376 KB
testcase_03 AC 1,452 ms
4,380 KB
testcase_04 AC 1,533 ms
4,380 KB
testcase_05 AC 1,475 ms
4,376 KB
testcase_06 AC 1,572 ms
4,380 KB
testcase_07 AC 1,520 ms
4,380 KB
testcase_08 AC 1,553 ms
4,376 KB
testcase_09 AC 1,567 ms
4,380 KB
testcase_10 AC 1,556 ms
4,380 KB
testcase_11 AC 1,482 ms
4,380 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘long long int f(int, int)’:
main.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

ll f(int a, int b){
    REP(i, 5){
        if(i != a && i != b){
            return i;
            break;
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    ll one = 0, two = 0, el;
    ll cnt = 0, ans = 0;
    rep(i, n)one += (a[i] == 1);
    rep(i, n)two += (a[i] == 2);
    el = n - one - two;
    
    //mex(a_i, a_j) = 2
    cnt += one*(one-1)/2;
    ans += one*(one-1);
    cnt += one*el;
    ans += one*el*2;

    //mex(a_i, a_j) = 3
    cnt += one*two;
    ans += one*two*3;

    //mex(a_i, a_j) = 1
    ans += n*(n-1)/2-cnt;
    //cout << ans  << endl;

    ll sum = 0;
    rep(i, n)rep(j, n){
        if(i <= j)continue;
        sum += f(a[i], a[j]);
    }
    cout << sum << endl;
}
0