結果
問題 |
No.3164 [Chery 7th Tune B] La vie en rose
|
ユーザー |
👑 |
提出日時 | 2024-07-21 09:46:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 489 bytes |
コンパイル時間 | 606 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 43,368 KB |
最終ジャッジ日時 | 2025-05-30 21:01:26 |
合計ジャッジ時間 | 12,138 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 TLE * 1 -- * 23 |
ソースコード
I,R=input,range J=lambda:map(int,I().split()) N,*_=J() A=list(J()) S=[] i=j=s=0 while i<N: if A[i]: while j<N and A[j]:s+=A[j];j+=1 S+=[[i,j,s]];i=j else:i=j=i+1;s=0 s=len(S) for _ in R(int(I())): X,B=J();X-=1;l,r=0,s while l<r-1: m=(l+r)>>1 if S[m][0]>X:r=m else:l=m if s<1:a=0 elif X>=S[l][0]and S[l][1]>X:a=S[l][2]-A[X] else: a,l,r=S[l][2]if X==S[l][1]else 0,-1,s-1 while l+1<r: m=(l+r)>>1 if S[m][1]>X:r=m else:l=m if S[r][0]==X+1:a+=S[r][2] print(a+B)