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:总是WA。。哪位大牛帮忙看看或者给几组易错的数据 谢谢啦~In Reply To:总是WA。。哪位大牛帮忙看看或者给几组易错的数据 谢谢啦~ Posted by:VV at 2006-05-29 21:58:52 > #include <iostream> > #include <stdlib.h> > #include <vector> > #include <iomanip> > > using namespace std; > class com > { > public: > int b,p; > double r; > com(int,int); > bool operator<(com); > }; > com::com(int x,int y) > { > b=x; > p=y; > r=b*1.0/p; > } > > vector< vector<com> > vec; > vector< com > te; > > int main(int argc, char *argv[]) > { > int test,n,m,i,j; > cin>>test; > for(int ti=0;ti<test;ti++) > { > cin>>n; > vec.clear(); > for(j=0;j<n;j++) > { > te.clear(); > cin>>m; > int tempb,tempp; > for(i=0;i<m;i++) > { > cin>>tempb>>tempp; > com temp(tempb,tempp); > te.push_back(temp); > } > vec.push_back(te); > } > double gr,lr; > int gb,gp,lb; > double r=0; > for(i=0;i<vec[0].size();++i) > { > if(vec[0][i].r>r) > { > r=vec[0][i].r; > gb=i; > } > } > int b=vec[0][gb].b,p=vec[0][gb].p; > for(i=1;i<vec.size();++i) > { > gp=-1;gb=-1;lr=-1;lb=-1; > for(j=0;j<vec[i].size();++j) > { > if(vec[i][j].b>=b) > { > if(gb==-1) > { > gp=vec[i][j].p; > gb=j; > //cout<<"gb "<<gb<<endl; > } > else > { > if(vec[i][j].p<vec[i][gb].p) > { > gp=vec[i][j].p; > gb=j; > //cout<<"gb "<<gb<<endl; > } > } > } > else > { > if(lb==-1) > { > lr=vec[i][j].r; > lb=j; > //cout<<"lb "<<lb<<endl; > } > else > { > if(vec[i][j].r>vec[i][lb].r) > { > lr=vec[i][j].r; > lb=j; > //cout<<"lb "<<lb<<endl; > } > } > } > } > //cout<<gb<<" "<<lb<<endl; > if(lb==-1) > p+=vec[i][gb].p; > else if(gb==-1) > { > b=b<vec[i][lb].b?b:vec[i][lb].b; > p+=vec[i][lb].p; > } > else if(b*1.0/(p+vec[i][gb].p)>=vec[i][lb].b/(vec[i][lb].p+p)) > p+=vec[i][gb].p; > else > { > cout<<111<<endl; > b=b<vec[i][lb].b?b:vec[i][lb].b; > p+=vec[i][lb].p; > } > //cout<<"b: "<<b<<" p: "<<p<<endl; > } > cout<<fixed<<setprecision(3)<<b*1.0/p<<endl; > } > system("PAUSE"); > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator