We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
/* Enter your code here. Read input from STDIN. Print output to STDOUT */#include<iostream>#include<algorithm>usingnamespacestd;intmain(){intN;cin>>N;longlongX[N],Y[N];intV[N];inti,j,k;for(i=0;i<N;i++)cin>>X[i]>>Y[i]>>V[i];intbest=0;for(i=0;i<N;i++)for(j=i+1;j<N;j++){intsum1=0,sum2=0;for(k=0;k<N;k++){longlongsign=((Y[k]-Y[i])*(X[j]-X[i])-(X[k]-X[i])*(Y[j]-Y[i]));if(sign<0)sum1+=V[k];elseif(sign>0)sum2+=V[k];}best=max(best,max(max(min(sum1+V[i],sum2+V[j]),min(sum1+V[j],sum2+V[i])),max(min(sum1+V[i]+V[j],sum2),min(sum1,sum2+V[i]+V[j]))));}cout<<best<<endl;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Stars
You are viewing a single comment's thread. Return to all comments →