标签:ace hat show under http php href amount rom
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 int n; 5 while(cin>>n){ 6 puts("Yes"); 7 } 8 }
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 502768/502768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define LL long long 4 const int MAXN=100010; 5 int b[MAXN],n,m,l,r; 6 char s[15]; 7 class ST{ 8 public: 9 #define lc (id<<1) 10 #define rc (id<<1|1) 11 #define mid ((L+R)>>1) 12 13 int minb[MAXN<<2],sum[MAXN<<2],laz[MAXN<<2]; 14 15 void pushup(int id){ 16 sum[id]=sum[lc]+sum[rc]; 17 minb[id]=min(minb[lc],minb[rc]); 18 } 19 void pushdown(int id,int L,int R){ 20 if(laz[id]){ 21 laz[lc]+=laz[id],minb[lc]-=laz[id]; 22 laz[rc]+=laz[id],minb[rc]-=laz[id]; 23 laz[id]=0; 24 } 25 } 26 void build(int id,int L,int R){ 27 sum[id]=laz[id]=0; 28 if(L==R){ 29 scanf("%d",b+L); 30 minb[id]=b[L]; 31 return; 32 } 33 build(lc,L,mid); 34 build(rc,mid+1,R); 35 pushup(id); 36 } 37 void add(int id,int L,int R,int l,int r){ 38 39 if(L>=l&&R<=r){ 40 laz[id]++; 41 minb[id]--; 42 return ; 43 } 44 pushdown(id,L,R); 45 if(l<=mid) add(lc,L,mid,l,r); 46 if(r>mid) add(rc,mid+1,R,l,r); 47 pushup(id); 48 } 49 int query(int id,int L,int R,int l,int r){ 50 if(minb[id]>0&&L>=l&&R<=r){ 51 return sum[id]; 52 } 53 if(L==R){ 54 if(minb[id]<=0){ 55 int d=(-minb[id]+b[L])/b[L]; 56 sum[id]+=d; 57 minb[id]=b[L]-(-minb[id]/*+b[L]-d*b[L]*/)%b[L]; 58 } 59 return sum[id]; 60 } 61 else{ 62 pushdown(id,L,R); 63 int s=0; 64 if(l<=mid) s+=query(lc,L,mid,l,r); 65 if(r>mid) s+=query(rc,mid+1,R,l,r); 66 pushup(id); 67 return s; 68 } 69 } 70 }a; 71 int main(){ 72 while(scanf("%d%d",&n,&m)!=EOF){ 73 a.build(1,1,n); 74 while(m--){ 75 scanf("%s %d%d",s,&l,&r); 76 if(s[0]==‘a‘){ 77 a.add(1,1,n,l,r); 78 } 79 else{ 80 printf("%d\n",a.query(1,1,n,l,r)); 81 } 82 } 83 } 84 return 0; 85 }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define LL long long 4 int a[100010],b[100010]; 5 LL C[100010],n; 6 map<int,int>M; 7 set<int>S; 8 set<int>::iterator it; 9 int lowbit(int x){ 10 return x&-x; 11 } 12 int sum(int x){ 13 LL ret=0; 14 while(x>0){ 15 ret+=C[x]; 16 x-=lowbit(x); 17 } 18 return ret; 19 } 20 void add(int x,int d){ 21 while(x<=n){ 22 C[x]+=d; 23 x+=lowbit(x); 24 } 25 } 26 int main(){ 27 int x,y,i,j,k; 28 while(cin>>n>>x>>y){ 29 memset(C,0,sizeof(C)); 30 M.clear(); 31 S.clear(); 32 LL ans=0; 33 for(i=1;i<=n;++i){ 34 scanf("%d",a+i); 35 b[i]=a[i]; 36 } 37 int tot=0; 38 sort(b+1,b+1+n); 39 for(i=1;i<=n;++i){ 40 if(M[b[i]]) continue; 41 M[b[i]]=++tot; 42 } 43 44 for(i=n;i>=1;--i){ 45 ans+=sum(M[a[i]]-1); 46 add(M[a[i]],1); 47 } 48 cout<<ans*min(x,y)<<endl; 49 } 50 return 0; 51 }
标签:ace hat show under http php href amount rom
原文地址:https://www.cnblogs.com/zzqc/p/9368891.html