結果

問題 No.2111 Sum of Diff
ユーザー lilictakalilictaka
提出日時 2022-11-04 13:45:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 946 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 135,124 KB
最終ジャッジ日時 2023-09-25 17:02:36
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,360 KB
testcase_01 AC 72 ms
71,260 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
mod = 998244353
n = len(set(A))
ans = 0
cumJ = 0
cumI = 0
ope = lambda x,y:(x+y) % mod
base = 1
for i in range(N):
    ans -=(cumJ * pow(2,N-1-i))%mod * A[i]
    ans %=mod
    '''
    ans += segJ.sum(0,zipped[i]) * pow(2,N-1-i) * A[i]
    ans %=mod
    '''
    cumJ += base
    cumJ %=mod
    base *=2
    base %=mod
rev2 = pow(2,mod-2,mod)
cumI = [0] * N
cumI[0] = 1
for i in range(1,N):
    cumI[i] = cumI[i-1] * rev2
    cumI[i] %=mod
def acum(List):#累積和
    rev = [0 for _ in range(len(List))]
    for i in range(len(List)):
        if i == 0:
            rev[i] = List[i]
        else:
           rev[i] = rev[i-1] + List[i] 
        rev[i] %=mod
    return rev
cumI = acum(cumI)
for i in reversed(range(N)):
    '''

    ans -= segI.sum(zipped[i]+1,n) * pow(2,N-1+i) * A[i]
    ans %=mod
    '''
    ans += (cumI[N-1]-cumI[i]) * pow(2,N-1+i) % mod * A[i]
    ans %=mod
print(ans)


0