結果
問題 | No.1470 Mex Sum |
ユーザー |
👑 ![]() |
提出日時 | 2021-04-09 21:29:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 420 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 82,024 KB |
実行使用メモリ | 101,204 KB |
最終ジャッジ日時 | 2024-06-25 04:11:58 |
合計ジャッジ時間 | 5,453 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
""" """ import sys from sys import stdin N = int(stdin.readline()) A = list(map(int,stdin.readline().split())) one = 0 two = 0 other = 0 for i in A: if i == 2: two += 1 elif i == 1: one += 1 else: other += 1 ans = 0 ans += 2 * (one * (one-1)//2) ans += 2 * (one * other) ans += 3 * (one * two) ans += 1 * ( N*(N-1)//2 - one * (one-1)//2 - one * two - one * other) print (ans)