結果
| 問題 |
No.3164 [Chery 7th Tune B] La vie en rose
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-29 10:42:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 965 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 352 ms |
| コンパイル使用メモリ | 82,240 KB |
| 実行使用メモリ | 134,496 KB |
| 最終ジャッジ日時 | 2025-06-29 10:43:08 |
| 合計ジャッジ時間 | 28,221 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
N = int(input())
A = [0]+list(map(int,input().split()))
B = [0]*(N+1)
i = 1
flag = 0
cnt = 0
while i<N+1:
if A[i]==0 and flag>0:
for j in range(flag,i):
B[j] = cnt
cnt = 0
flag = 0
elif A[i]>0 and flag==0:
flag = i
cnt += A[i]
elif A[i]>0 and flag>0:
cnt += A[i]
i += 1
if flag:
for j in range(flag,N+1):
B[j] = cnt
Q = int(input())
for _ in range(Q):
x,b = map(int,input().split())
if B[x]>0:
print(B[x]+b-A[x])
elif x<N:
print(b+B[x-1]+B[x+1])
else:
print(b+B[x-1])