結果

問題 No.1470 Mex Sum
ユーザー Aurora
提出日時 2021-04-10 18:55:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 1,651 ms
コンパイル使用メモリ 169,508 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-26 07:48:25
合計ジャッジ時間 5,131 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    long long int N,ans=0;
    cin >> N;
    vector<long long int> cnt(3,0);
    for(int i=0;i<N;i++){
        long long int A;
        cin >> A;
        if(A == 1) cnt[0]++;
        if(A == 2) cnt[1]++;
        if(A >= 3) cnt[2]++;
    }
    ans += cnt[0]*(cnt[0]-1);
    ans += 3*cnt[0]*cnt[1];
    ans += 2*cnt[0]*cnt[2];
    ans += (N-cnt[0])*(N-cnt[0]-1);
    cout << ans << endl;
}
0