fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef pair<long long int,long long int> pll;
  4. typedef pair<pll,int> ppi;
  5. const int MAXN = 100005;
  6. int y_sum[MAXN];
  7. long double prob[MAXN],yp_sum[MAXN];
  8. bool sorter(const ppi &a, const ppi &b)
  9. {
  10. long long int x1 = a.first.first, y1 = a.first.second;
  11. long long int x2 = b.first.first, y2 = b.first.second;
  12. long long int cp = (x1*y2 - x2*y1);
  13. if(cp != 0)
  14. return (cp > 0);
  15. long long int d1 = x1*x1 + y1*y1, d2 = x2*x2 + y2*x2;
  16. if(d1 != d2)
  17. return (d1 < d2);
  18. return (a.second < b.second);
  19. }
  20. int main()
  21. {
  22. int n;
  23. scanf("%d", &n);
  24. vector <ppi> A;
  25. for (int i = 0; i < n; ++i)
  26. {
  27. int x,y,p;
  28. scanf("%d %d %d", &x, &y, &p);
  29. A.push_back(ppi(pll(x,y),i));
  30. prob[i] = p/100.0;
  31. }
  32. sort(A.begin(), A.end(), sorter);
  33. for (int i = 0; i < n; ++i)
  34. {
  35. A.push_back(A[i]);
  36. A.back().first.first*=-1;
  37. A.back().first.second*=-1;
  38. }
  39. long double ans = 0, tot_y = 0;
  40. for (int i = 0; i < A.size(); ++i)
  41. {
  42. long double y = A[i].first.second/2.0 + tot_y;
  43. y-=yp_sum[A[i].second];
  44. y+=y_sum[A[i].second];
  45. ans-=y*A[i].first.first*prob[A[i].second];
  46. long double yp = A[i].first.second*prob[A[i].second];
  47. tot_y+=yp;
  48. yp_sum[A[i].second]+=yp;
  49. y_sum[A[i].second]+=A[i].first.second;
  50. }
  51. double fans = ans;
  52. printf("%.10lf\n", fans);
  53. return 0;
  54. }
Success #stdin #stdout 0s 6152KB
stdin
Standard input is empty
stdout
0.0000000000