結果
| 問題 | 
                            No.3164 [Chery 7th Tune B] La vie en rose
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-05-30 21:36:16 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 907 ms / 2,000 ms | 
| コード長 | 455 bytes | 
| コンパイル時間 | 586 ms | 
| コンパイル使用メモリ | 82,360 KB | 
| 実行使用メモリ | 166,644 KB | 
| 最終ジャッジ日時 | 2025-05-30 21:36:43 | 
| 合計ジャッジ時間 | 26,303 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 34 | 
ソースコード
N = int(input())
A = list(map(int, input().split()))
R = [0]
for i in range(N - 1, 0, -1):
    if A[i] == 0:
        R.append(0)
    else:
        R.append(R[-1] + A[i])
R.reverse()
#print(R)
L = [0]
for i in range(N - 1):
    if A[i] == 0:
        L.append(0)
    else:
        L.append(L[-1] + A[i])
#print(L)
Q = int(input())
for _ in range(Q):
    
    X, B = map(int, input().split())
    X -= 1
    
    print(R[X] + L[X] + B)