#include#include #include #include using namespace std; const int N = 200010; #define int long long int n; struct node { int z,x,y; bool operator < (const node & W)const { return z heap; cin>>n; for(int i=1;i<=n;i++) { int z,x,y;cin>>z>>x>>y; a[i]={z,x,y}; } sort(a+1,a+n+1,cmp); int tmp=0; double res=0.0; for(int i=1;i<=n;i++) { heap.push(a[i]); tmp+=a[i].x; if(tmp>a[i].y) { int num=tmp-a[i].y; tmp=a[i].y; while(heap.size()) { if(num==0)break; auto t=heap.top();heap.pop(); if(num>t.x) { res+=(double)t.x*1.0/t.z; num-=t.x; } else { res+=(double)num*1.0/t.z; t.x-=num; heap.push(t); num=0; } } } } printf("%.1lfn",res); }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)