結果
問題 |
No.1099 Range Square Sum
|
ユーザー |
👑 ![]() |
提出日時 | 2020-06-26 21:52:05 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 766 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 265,324 KB |
最終ジャッジ日時 | 2024-07-04 20:44:06 |
合計ジャッジ時間 | 5,693 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 TLE * 1 -- * 9 |
ソースコード
class Imos_1: def __init__(self,N): self.len=N self.list=[0]*(N+1) def Add(self,F,T,C): self.list[F]+=C self.list[T+1]-=C def Cumulative_Sum(self): Y=[0]*(self.len) S=0 for i in range(self.len): S+=self.list[i] Y[i]=S return Y #---------------------------------------------------------- N=int(input()) A=list(map(int,input().split())) Q=int(input()) S=Imos_1(N) for i in range(Q): K=list(map(int,input().split())) if K[0]==1: _,l,r,x=K S.Add(l-1,r-1,x) else: _,l,r=K T=0 Y=S.Cumulative_Sum() for i in range(l-1,r): p=A[i] q=Y[i] T+=(p+q)*(p+q) print(T)