結果
| 問題 | No.1233 割り切れない気持ち |
| コンテスト | |
| ユーザー |
uni_python
|
| 提出日時 | 2020-09-20 15:57:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 974 bytes |
| 記録 | |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 160,128 KB |
| 最終ジャッジ日時 | 2024-06-24 10:47:29 |
| 合計ジャッジ時間 | 16,763 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 TLE * 1 -- * 13 |
ソースコード
import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
"""
A[i]=aを見る時
aより小さい数は全部そのまま足す,
aより大きく,2aより小さいものは全部足して,個数*aを引く
此の要領で
"""
def main():
import bisect
mod=10**9+7
N=I()
A=LI()
A.sort()
M=A[-1]
S=[0]*(N+1)
for i in range(N):
S[i+1]=S[i]+A[i]
def calc(a):
if a==1:
return 0
res=0
now=a
num1=0
while now<=M+a:
num2=bisect.bisect_left(A,now)
temp=S[num2] - S[num1]
temp-=(num2-num1)*(now-a)
res+=temp
num1=num2
now+=a
return res
ans=0
for a in A:
ans+=calc(a)
print(ans)
main()
uni_python