結果
問題 |
No.1470 Mex Sum
|
ユーザー |
|
提出日時 | 2021-04-09 22:26:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 109,824 KB |
最終ジャッジ日時 | 2024-06-25 06:02:11 |
合計ジャッジ時間 | 7,420 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 49 |
ソースコード
N=int(input()) A=list(map(int,input().split())) from collections import Counter one,two=0,0 other=0 l=[[0]*3 for i in range(N+1)] for i in range(N): l[i+1][0]=l[i][0] l[i+1][2]=l[i][2] l[i+1][1]=l[i][1] if A[i]==1: l[i+1][0]+=1 elif A[i]==2: l[i+1][1]+=1 else: l[i+1][2]+=1 ans=0 for i,j in enumerate(A): tmp_l=l[i] if j==1: ans+=tmp_l[0]*2+tmp_l[1]*3+tmp_l[2]*2 elif j==2: ans+=tmp_l[0]*3+tmp_l[1]+tmp_l[2] else: ans+=tmp_l[0]*2+tmp_l[1]+tmp_l[2] print(ans)