Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:没有语言了!检查了n遍了还是WA!In Reply To:没有语言了!检查了n遍了还是WA! Posted by:liyanguestc at 2006-08-23 13:43:43 > #include <iostream> > #include <algorithm> > using namespace std; > int main() > { > int M; > int N; > int minc; > int maxc; > cin>>M>>N>>minc>>maxc; > int *wet=new int[M]; > int *sou=new int[N]; > for(int i=0;i<M;i++) > cin>>wet[i]; > for(i=0;i<N;i++) > cin>>sou[i]; > sort(wet,wet+M-1); > sort(sou,sou+N-1); > ////////////////////// > int maxM=0,maxN=0; > for(i=0;i<M;i++) > if(wet[i]>maxM) > maxM=wet[i]; > for(i=0;i<N;i++) > if(sou[i]>maxN) > maxN=sou[i]; > if(maxM!=maxN) > {cout<<"Impossible"<<endl; > return 0; > } > //////////"Impossible判断"/////////////// > > > int maxfloor=0,minfloor=0; > > int j; > int cur=0; > for(i=0;i<M;i++) > { > for(j=cur;j<N;j++,cur++) > if(wet[i]<=sou[j]) > {maxfloor+=(N-j)*wet[i]; > break; > } > } > cur=0; > for(i=0;i<N;i++) > { > for(j=cur;j<M;j++,cur++) > if(sou[i]<wet[j]) > {maxfloor+=(M-j)*sou[i]; > break; > } > } > > > ///////////////求得最大maxfloor/////////////////// > cur=0; > for(i=0;i<M;i++) > { if(cur==N) > {minfloor+=wet[i]; > continue; > } > for(j=cur;j<N;j++,cur++) > if(wet[i]==sou[j]) > {minfloor+=sou[j]; > cur++; > break; > } > else if(wet[i]<sou[j]) > {minfloor+=wet[i]; > break; > } > else if(wet[i]>sou[j]) > { > minfloor+=sou[j]; > > } > } > > ///////////////求得最小minfloor////////////////// > cout<<"Minimum: "<<minfloor*minc<<","<<" maximum: "<<maxfloor*maxc<<endl; > > > delete[] wet; > delete[] sou; > > return 0; > > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator