結果

問題 No.1470 Mex Sum
ユーザー 佐藤竜也
提出日時 2021-06-24 12:41:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 1,591 ms
コンパイル使用メモリ 168,112 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 07:28:50
合計ジャッジ時間 4,714 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll INF = 1000000000000000000;

// rep(i, 0, 4) => 上下左右, rep(i, 0, 8) => 斜めも含む
vector<int> dy = {-1, 0, 1, 0, -1, -1, 1, 1};
vector<int> dx = {0, 1, 0, -1, -1, 1, 1, -1};

int main() {
    int N;
    cin >> N;
    int X = 0, Y = 0, Z = 0;
    rep(i, 0, N) {
        int a;
        cin >> a;
        if (a == 1) X++;
        else if (a == 2) Y++;
        else Z++;
    }
    cout << X * (X - 1) + Y * (Y - 1) / 2 * Z * (Z - 1) / 2 + 3 * X * Y + Y * Z + 2 * X * Z << endl;
}
0