結果

問題 No.1470 Mex Sum
ユーザー yushi529
提出日時 2021-04-12 11:12:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 1,566 ms
コンパイル使用メモリ 167,936 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 09:09:27
合計ジャッジ時間 4,800 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n;
   cin >> n;
   vector<int> a(n);
   int cnt1 = 0, cnt2 = 0;
   for (int i = 0; i < n; i++) {
       cin >> a[i];
       cnt1 += (a[i] == 1);
       cnt2 += (a[i] == 2);
   }
   int cnt3 = n - cnt1 - cnt2;
   long long ans = 0;
   ans += cnt1 * cnt2 * 3;
   ans += cnt1 * cnt3 * 2 + cnt1 * (cnt1 - 1) / 2 * 2;
   ans += cnt2 * (cnt2 - 1) / 2 + cnt2 * cnt3 + cnt3 * (cnt3 - 1) / 2;
   cout << ans << endl;
}
0