真心没啥好说的了,求个中位数吧
PS:吐槽下,后面的.00000是故意恶心人的么?
//SGU 114 Telecasting station //中位数 //by night_watcher #include<iostream> #include<algorithm> using namespace std; #define N 15001 int n; struct NODE{ int x,p; }node[N]; bool cmp(const NODE a,const NODE b){ return a.x<b.x; } int main(){ int i,j,p=0,sum=0; cin>>n; for(i=0;i<n;i++){ cin>>node[i].x>>node[i].p; p+=node[i].p; } sort(node,node+n,cmp); ++p/=2; for(i=0;;i++){ sum+=node[i].p; if(sum>=p) break; } cout<<node[i].x; cout<<".00000"<<endl; return 0; }