#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+10;
int n,m;
LL v[N],l[N],r[N];
struct BIT{
LL sum[N];
void add(int x,LL y){
for( ;x<N;x+= x&-x){
sum[x]+=y;
}
}
LL qur(int x){
LL res=0;
for( ;x;x-=x&-x){
res+=sum[x];
}
return res;
}
LL qursuf(int x){
return qur(N-1)-qur(x-1);
}
}ds1,ds2;
bool check(int mid) {
LL p = ds2.qursuf(mid + 1), q = ds1.qursuf(mid + 1) + r[0];
return mid * q < p;
}
LL gcd(LL x, LL y) {
if(y==0){
return x;
}
return gcd(y, x % y);
}
void calc(){
int lt=0,rt=N-1,pos=0;
for(;lt<=rt; ){
int mid=(lt+rt)/2;
if(check(mid)){
pos=mid;
lt=mid+1;
}
else{
rt=mid-1;
}
}
LL p=ds2.qursuf(pos + 1);
LL q=ds1.qursuf(pos+1)+r[0];
if(q==0){
q=1;
}
LL d=gcd(p,q);
printf("%lld/%lld\n",p/d,q/d);
}
int main() {
freopen("market.in", "r", stdin);
freopen("market.out", "w", stdout);
scanf("%d%d", &n, &m);
for(int i=1;i<=n;i++){
scanf("%lld",&v[i]);
}
for(int i=0;i<=n;i++){
scanf("%lld",&l[i]);
}
for(int i=0;i<=n;i++){
scanf("%lld",&r[i]);
}
for(int i=1;i<=n;i++){
ds1.add(v[i],l[i]);
ds2.add(v[i],v[i]*l[i]);
}
calc();
for(int i=1;i<=m;i++){
int op,x,y,z;
scanf("%d%d%d", &op, &x, &y);
if (op == 1) {
scanf("%d", &z);
if (x == 0) {
l[x] = y, r[x] = z;
} else {
ds1.add(v[x], -l[x]);
ds2.add(v[x], -v[x] * l[x]);
l[x]=y;
r[x]=z;
ds1.add(v[x],l[x]);
ds2.add(v[x],v[x]*l[x]);
}
}
else{
ds1.add(v[x],-l[x]);
ds2.add(v[x],-v[x]*l[x]);
v[x]=y;
ds1.add(v[x],l[x]);
ds2.add(v[x],v[x]*l[x]);
}
calc();
}
return 0;
}
07-17
557
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-18
4576
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-06
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交