求条!!!!
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 10;
using LL = long long;
LL a[N], b[N], tr[N];
int lowbit(int x) { return x & (-x); }
void add(int x, LL y) {
for (int i = x; i < N; i += lowbit(i)) {
tr[i] += y;
}
}
LL sum(int x) {
LL ans = 0;
for (int i = x; i; i -= lowbit(i)) {
ans += tr[i];
}
return ans;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
add(i, a[i]);
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
set<int> st;
for (int i = 1; i <= n; i++) {
if (b[i] > 1) {
st.insert(i);
}
}
int q;
cin >> q;
while (q--) {
int op, x, y;
cin >> op >> x >> y;
if (op == 1) {
add(x, -a[x]);
a[x] = y;
add(x, a[x]);
} else if (op == 2) {
if (b[x] > 1) {
st.erase(x);
}
b[x] = y;
if (b[x] > 1) {
st.insert(x);
}
} else {
int l = x, r = y;
l--;
LL ans = 0;
while (l < r) {
auto it = st.upper_bound(l);
if (it == st.end()) {
ans += sum(r) - sum(l);
break;
}
int pos = (*it);
ans += sum(pos - 1) - sum(l);
ans = max(ans * b[pos], ans + a[pos]);
l = pos;
}
cout << ans << "\n";
}
}
return 0;
}