結果

問題 No.2300 Substring OR Sum
ユーザー 👑 timitimi
提出日時 2023-05-13 17:18:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 435 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 259,280 KB
最終ジャッジ日時 2024-05-06 22:47:04
合計ジャッジ時間 5,729 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,840 KB
testcase_01 AC 34 ms
51,584 KB
testcase_02 AC 36 ms
51,584 KB
testcase_03 AC 160 ms
110,124 KB
testcase_04 AC 157 ms
107,396 KB
testcase_05 AC 164 ms
115,472 KB
testcase_06 AC 116 ms
92,928 KB
testcase_07 AC 404 ms
256,900 KB
testcase_08 AC 200 ms
128,864 KB
testcase_09 AC 176 ms
116,948 KB
testcase_10 AC 362 ms
212,132 KB
testcase_11 AC 375 ms
233,660 KB
testcase_12 AC 435 ms
258,572 KB
testcase_13 AC 278 ms
259,280 KB
testcase_14 AC 286 ms
258,056 KB
testcase_15 AC 215 ms
137,552 KB
testcase_16 AC 351 ms
214,900 KB
testcase_17 AC 392 ms
258,960 KB
testcase_18 AC 37 ms
51,584 KB
testcase_19 AC 39 ms
51,968 KB
testcase_20 AC 40 ms
51,584 KB
testcase_21 AC 39 ms
51,840 KB
testcase_22 AC 41 ms
51,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
#N,A,B=map(int,input().split())
A=list(map(int, input().split()))
ans=0
for i in range(30):
  D=[]
  for a in A:
    if (a&(1<<i)):
      D.append(1)
    else:
      D.append(0)
  B=[]
  now=0
  for d in D:
    if d==0:
      now+=1 
    else:
      if now!=0:
        B.append(now)
      now=0
  if now!=0:
    B.append(now)
  c=N*(N+1)//2 
  for b in B:
    c-=b*(b+1)//2 
  ans+=pow(2,i)*c
print(ans)    
    
0