結果

問題 No.1470 Mex Sum
ユーザー terry_u16
提出日時 2021-04-09 22:00:48
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 3,271 ms
コンパイル使用メモリ 119,552 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 05:26:56
合計ジャッジ時間 4,179 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);

    for (size_t i = 0; i < n; i++)
    {
        std::cin >> a[i];
    }

    long long one, two, more;
    one = 0;
    two = 0;

    for (auto ai : a)
    {
        if (ai == 1)
        {
            one++;
        }
        else if (ai == 2)
        {
            two++;
        }
    }

    more = n - one - two;

    long long result = 0;

    result += (two + more) * (two + more - 1) / 2;
    result += 2 * (one + more) * (one + more - 1) / 2;
    result += 3 * one * two;
    std::cout << result << std::endl;
}
0