結果
問題 | No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない |
ユーザー |
![]() |
提出日時 | 2021-06-11 21:42:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 959 ms / 2,000 ms |
コード長 | 410 bytes |
コンパイル時間 | 542 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 117,732 KB |
最終ジャッジ日時 | 2024-12-14 22:57:11 |
合計ジャッジ時間 | 33,192 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 53 |
ソースコード
N=int(input()) mod=998244353 this=0 su=0 ans=0 L=list() for i in range(N): t,a=map(int,input().split()) L.append([t,a]) su+=t for i in range(N): thisans=0 t,a=L[i] this+=1 this2=this+t-1 n=this-1 m=this2 k=((m+2)*(m+1)*m//6)-((n+2)*(n+1)*n//6) thisans+=k*(su+1)*a f=(m*(m+1)*(m+2)*(3*m+1)//24)-(n*(n+1)*(n+2)*(3*n+1)//24) thisans-=f*a ans+=thisans ans%=mod this=this2 print(ans)