結果

問題 No.1233 割り切れない気持ち
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-03-04 11:16:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 3,153 ms
コード長 547 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,796 KB
実行使用メモリ 122,148 KB
最終ジャッジ日時 2024-04-15 04:27:29
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,372 KB
testcase_01 AC 38 ms
52,264 KB
testcase_02 AC 40 ms
52,440 KB
testcase_03 AC 44 ms
61,136 KB
testcase_04 AC 41 ms
60,548 KB
testcase_05 AC 36 ms
52,992 KB
testcase_06 AC 35 ms
53,292 KB
testcase_07 AC 79 ms
88,964 KB
testcase_08 AC 95 ms
95,776 KB
testcase_09 AC 145 ms
111,524 KB
testcase_10 AC 149 ms
116,160 KB
testcase_11 AC 80 ms
86,908 KB
testcase_12 AC 157 ms
121,344 KB
testcase_13 AC 162 ms
122,148 KB
testcase_14 AC 157 ms
121,328 KB
testcase_15 AC 154 ms
121,728 KB
testcase_16 AC 165 ms
121,648 KB
testcase_17 AC 74 ms
98,088 KB
testcase_18 AC 147 ms
121,604 KB
testcase_19 AC 96 ms
120,664 KB
testcase_20 AC 74 ms
97,972 KB
testcase_21 AC 78 ms
101,308 KB
testcase_22 AC 77 ms
101,840 KB
testcase_23 AC 78 ms
100,576 KB
testcase_24 AC 77 ms
100,152 KB
testcase_25 AC 79 ms
101,860 KB
testcase_26 AC 78 ms
100,820 KB
testcase_27 AC 103 ms
120,892 KB
testcase_28 AC 102 ms
120,836 KB
testcase_29 AC 98 ms
119,228 KB
testcase_30 AC 97 ms
119,176 KB
testcase_31 AC 97 ms
119,276 KB
testcase_32 AC 98 ms
119,432 KB
testcase_33 AC 96 ms
119,292 KB
testcase_34 AC 97 ms
119,556 KB
testcase_35 AC 96 ms
119,348 KB
testcase_36 AC 96 ms
119,248 KB
testcase_37 AC 35 ms
53,156 KB
testcase_38 AC 92 ms
115,588 KB
testcase_39 AC 125 ms
120,068 KB
testcase_40 AC 126 ms
119,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(n,a):
  ret=n*sum(a)
  m=max(a)
  ary=[0]*(m+1)
  for x in a:ary[x]+=1
  sary=[0]
  for x in ary:sary.append(sary[-1]+x)
  memo={}
  for x in a:
    if x in memo:
      ret+=memo[x]
      continue
    tmp=0
    i=1
    while i*x<=m:
      # xで割った商がiになる数字の個数
      # [i*x,(i+1)*x)
      s=i*x
      e=min((i+1)*x,m+1)
      t=sary[e]-sary[s]
      tmp-=i*x*t
      i+=1
    memo[x]=tmp
    ret+=tmp
  return ret
if __name__=='__main__':
  n=int(input())
  a=list(map(int,input().split()))
  print(main1(n,a))
0