結果

問題 No.1470 Mex Sum
ユーザー Laika
提出日時 2021-04-09 23:30:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 190,900 KB
最終ジャッジ日時 2025-01-20 15:17:30
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int n;
int cnt[3];

int main() {

  cin >> n;
  for (int i = 0; i < n; ++i) {
    int A;
    cin >> A;
    if (A > 3)
      A = 3;
    ++cnt[A - 1];
  }

  ll ans = 0;
  ans +=
      cnt[1] * (cnt[1] - 1) / 2 + cnt[2] * (cnt[2] - 1) / 2 + cnt[1] * cnt[2];
  ans += cnt[0] * (cnt[0] - 1) + 2 * cnt[0] * cnt[2];
  ans += 3 * cnt[0] * cnt[1];

  cout << ans << '\n';

  return 0;
}

0