結果

問題 No.1470 Mex Sum
コンテスト
ユーザー LyricalMaestro
提出日時 2025-09-20 17:51:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 88 ms / 2,000 ms
+ 819µs
コード長 545 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 228 ms
コンパイル使用メモリ 95,984 KB
実行使用メモリ 112,768 KB
最終ジャッジ日時 2026-07-15 04:22:33
合計ジャッジ時間 7,026 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/2944


def main():
    N = int(input())
    A = list(map(int, input().split()))

    a_counts = [0] * 4
    for a in A:
        x = min(a, 3)
        a_counts[x] += 1

    answer = 0
    # 回答が一
    n = a_counts[2] + a_counts[3]
    answer += (n * (n - 1)) // 2

    # 回答が2
    answer += 2 * a_counts[1] * a_counts[3]
    n = a_counts[1]
    answer += 2 * ((n * (n - 1)) //2)

    # 回答3
    answer += 3 * a_counts[1] * a_counts[2]
  

    print(answer)


if __name__ == "__main__":
    main()
0