結果
問題 | No.1470 Mex Sum |
ユーザー |
![]() |
提出日時 | 2021-04-09 22:16:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 1,461 ms |
コンパイル使用メモリ | 165,124 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 05:48:37 |
合計ジャッジ時間 | 3,669 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
#include<bits/stdc++.h> using namespace::std; const int N = 200000 + 5; int n; int a[N]; int main(){ scanf("%d", &n); long long extra = 0, ones = 0, twos = 0; for(int i = 0; i < n; i++){ scanf("%d", a + i); if(a[i] == 1) ones += 1; else if(a[i] == 2) twos += 1; else extra += 1; } long long ans = 2 * extra * ones + 1 * extra * twos + 3 * ones * twos + 2 * ones * (ones - 1) / 2 + 1 * extra * (extra - 1) / 2 + 1 * twos * (twos - 1) / 2; printf("%lld\n", ans); return 0; }