結果
| 問題 | 
                            No.1470 Mex Sum
                             | 
                    
| コンテスト | |
| ユーザー | 
                             srjywrdnprkt
                         | 
                    
| 提出日時 | 2023-06-19 14:55:41 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 381 bytes | 
| コンパイル時間 | 2,003 ms | 
| コンパイル使用メモリ | 191,624 KB | 
| 最終ジャッジ日時 | 2025-02-14 22:55:29 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 14 WA * 35 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N, ans=0, A, a=0, b=0;
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> A;
        if (A == 1) a++;
        else if (A == 2) b++;
    }
    ans += (a*(a-1)/2+a*(N-a-b))*2;
    ans += a*b*3;
    ans += (N*(N-1)/2-a*(a-1)/2+a*(N-a-b)-a*b);
    cout << ans << endl;
    return 0;
}
            
            
            
        
            
srjywrdnprkt