标签:status mst bubuko NPU stream ges efi rip mem
1 #include<cstring> 2 #include<cstdio> 3 #include<algorithm> 4 #include<iostream> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 9 #define N 50007 10 #define ls p<<1 11 #define rs p<<1|1 12 using namespace std; 13 inline int read() 14 { 15 int x=0,f=1;char ch=getchar(); 16 while(!isdigit(ch)){if(ch==‘-‘)f=-1;ch=getchar();} 17 while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-‘0‘;ch=getchar();} 18 return x*f; 19 } 20 21 int n,tot; 22 double ans; 23 int tr[N<<2]; 24 char ch[20]; 25 struct Node 26 { 27 double k,b; 28 }a[N<<1]; 29 30 bool judge(int x,int y,int t) 31 { 32 t--; 33 return a[x].b+a[x].k*t>a[y].b+a[y].k*t; 34 } 35 void ins(int p,int l,int r,int x) 36 { 37 if (l==r) 38 { 39 if (judge(x,tr[p],l)) tr[p]=x; 40 return; 41 } 42 int mid=(l+r)>>1; 43 if (a[x].k>a[tr[p]].k) 44 { 45 if (judge(x,tr[p],mid)) ins(ls,l,mid,tr[p]),tr[p]=x; 46 else ins(rs,mid+1,r,x); 47 } 48 else 49 { 50 if (judge(x,tr[p],mid)) ins(rs,mid+1,r,tr[p]),tr[p]=x; 51 else ins(ls,l,mid,x); 52 } 53 } 54 void query(int p,int l,int r,int x) 55 { 56 ans=max(ans,a[tr[p]].k*(x-1)+a[tr[p]].b); 57 if (l==r) return; 58 int mid=(l+r)>>1; 59 if (x<=mid) query(ls,l,mid,x); 60 else query(rs,mid+1,r,x); 61 } 62 int main() 63 { 64 n=read(); 65 for (int i=1;i<=n;i++) 66 { 67 scanf("%s",ch); 68 if (ch[0]==‘P‘) 69 { 70 tot++; 71 scanf("%lf%lf",&a[tot].b,&a[tot].k); 72 ins(1,1,n,tot); 73 } 74 else 75 { 76 ans=0;query(1,1,n,read()); 77 printf("%d\n",(int)ans/100); 78 } 79 } 80 }
bzoj 1568 [JSOI2008]Blue Mary开公司 超哥线段树
标签:status mst bubuko NPU stream ges efi rip mem
原文地址:https://www.cnblogs.com/fengzhiyuan/p/8847520.html