結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2021-06-01 01:31:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 113 ms / 2,000 ms |
コード長 | 337 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 102,144 KB |
最終ジャッジ日時 | 2024-11-09 00:05:07 |
合計ジャッジ時間 | 7,174 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
def mex(a,b): num = 0 if a == 1: if b == 2: num = b+1 else: num = 2 else: num = a-1 return num N = int(input()) A = list(map(int,input().split())) A.sort() c1 = A.count(1) ans = max(0,c1*(c1-1)) num = A[0] for i in range(c1,N): ans += (mex(num,A[i])*c1) ans += max(0,(N-c1)*(N-c1-1)//2) print(ans)