|
|
back to boardWA4 Please give me some tests this is my code: #include <iostream> using namespace std; int main() { long sj,prj1,prj2,n,k,sd[256],prd[256],kom[256],sh[256],prh[256]; cin>>sj>>prj1>>prj2>>n; for(int i=0;i<n;i++) cin>>sd[i]>>prd[i]; cin>>k; for(int i=0;i<k;i++) cin>>kom[i]>>sh[i]>>prh[i];
long max=-1,nh=0,nd=0;
for(int i=0;i<k;i++) if(kom[i]==1) { if(sh[i]<=sj&&(prj1+prh[i]>max)) {max=prj1+prh[i];nh=i+1;nd=0;}} else { if(sh[i]<=sj&&(prj2+prh[i]>max)) {max=prj2+prh[i];nh=i+1;nd=0;} for(int j=0;j<n;j++) if(sh[i]<=int(double(sj)/2.0+double(sd[j])/2.0)&&(prh[i]+prd[j]>max)) {max=prh[i]+prd[j];nh=i+1;nd=j+1;} }
if(nd==0) {if(nh==0) cout<<"Forget about apartments. Live in the dormitory."<<endl; else cout<<"You should rent the apartment #"<<nh<<" alone."<<endl; } else cout<<"You should rent the apartment #"<<nh<<" with the friend #"<<nd<<"."<<endl;
return 0; } Edited by author 29.11.2014 15:08 |
|
|