[李超线段树 模板题] BZOJ 1568 [JSOI2008]Blue Mary开公司
2017-02-01 22:42
537 查看
模板题 复习下 顺便骗骗访问量
奇怪的是这个题上网找标程
自己和标程对拍拍出错 标程之间对拍也拍出错
但就是都A了
奇怪的是这个题上网找标程
自己和标程对拍拍出错 标程之间对拍也拍出错
但就是都A了
#include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; } return *p1++; } inline void read(int &x){ char c=nc(),b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b; } inline void read(char &x){ for (x=nc();!(x>='A' && x<='Z');x=nc()); } #define C (c=nc()) inline void read(double &x){ char c;int p=1; double t=10; x=0; while (C!='-'&&'0'>c||c>'9'); if (c=='-') p=-1,C; while ('0'<=c&&c<='9') x=x*10+c-'0',C; if (c=='.') while ('0'<=C&&c<='9') x+=(c-'0')/t,t*=10; x*=p; } inline int dcmp(double a,double b){ if (fabs(a-b)<1e-5) return 0; if (a<b) return -1; return 1; } const int N=100005; int T[N<<2],F[N<<2]; double A[N<<2],B[N<<2]; inline void Flag(int x,int l,int r,double a,double b){ if (!F[x]) { F[x]=1,A[x]=a,B[x]=b; return; } int mid=(l+r)>>1,len=mid-l; if (dcmp(A[x],a)==0 || l==r) { B[x]=min(B[x],b); return; } if (a>A[x] && b>B[x]) A[x]=a,B[x]=b; else if (a>A[x] && b<=B[x]){ if (A[x]*len+B[x]>a*len+b) Flag(x<<1|1,mid+1,r,a,b+a*(len+1)); else swap(A[x],a),swap(B[x],b),Flag(x<<1,l,mid,a,b); }else if (a<A[x] && b>=B[x]){ if (A[x]*len+B[x]>a*len+b) Flag(x<<1,l,mid,a,b); else swap(A[x],a),swap(B[x],b),Flag(x<<1|1,mid+1,r,a,b+a*(len+1)); } } double ans; inline void Query(int x,int l,int r,int t){ if (F[x]) ans=max(ans,A[x]*(t-l)+B[x]); if (l==r) return; int mid=(l+r)>>1; if (t<=mid) Query(x<<1,l,mid,t); else Query(x<<1|1,mid+1,r,t); } int n=50000; int main(){ int Q,x; double a,b; char order; freopen("t.in","r",stdin); freopen("t.out","w",stdout); read(Q); while (Q--){ read(order); if (order=='Q'){ ans=0; read(x); Query(1,1,n,x); printf("%lld\n",(long long)(ans/100+1e-8)); }else{ read(b); read(a); Flag(1,1,n,a,b); } } return 0; }
相关文章推荐
- [bzoj1568][JSOI2008]Blue Mary开公司——李超线段树
- 【李超线段树】BZOJ1568[JSOI2008]Blue Mary开公司
- 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司
- 【BZOJ1568】[JSOI2008]Blue Mary开公司 线段树
- bzoj1568 [JSOI2008]Blue Mary开公司 标记永久化线段树
- 【bzoj1568】【JSOI2008】【Blue Mary开公司】【线段树】
- BZOJ 1568: [JSOI2008]Blue Mary开公司(超哥线段树)
- [JSOI2008]Blue Mary开公司(李超线段树)
- bzoj 1568: [JSOI2008]Blue Mary开公司
- BZOJ 1568 [JSOI2008]Blue Mary开公司
- [BZOJ1568][JSOI2008]Blue Mary开公司(超哥线段树)
- bzoj 1568: [JSOI2008]Blue Mary开公司
- bzoj1568: [JSOI2008]Blue Mary开公司 (超哥线段树)
- 【bzoj1568】[JSOI2008]Blue Mary开公司 超哥线段树
- Bzoj1568 [JSOI2008]Blue Mary开公司
- bzoj1568 [JSOI2008]Blue Mary开公司(超哥线段树)
- BZOJ 1568: [JSOI2008]Blue Mary开公司 标记永久化
- BZOJ1568: [JSOI2008]Blue Mary开公司
- BZOJ1568:[JSOI2008]Blue Mary开公司——题解
- 【bzoj1568】 JSOI2008—Blue Mary开公司