Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.   long p, d, r;
  6.   long va[100000] = {0};
  7.   long vb[100000] = {0};
  8.   long double a, b, ea, eb, te, e;
  9.   long double ta = 0.0;
  10.   long double tb = 0.0;
  11.   long double t = 0.0;
  12.  
  13.   cin>>p>>d;
  14.   while(p--){
  15.     cin>>r>>a>>b;
  16.     va[r] += a;
  17.     vb[r] += b;
  18.     t += a+b;
  19.   }
  20.  
  21.   for(int i = 1; i <= d; i++){
  22.     te = floor((va[i]+vb[i])/2)+1;
  23.     if(va[i] > vb[i]){
  24.       ea = va[i]-te;
  25.       eb = vb[i];
  26.       cout<<"A "<<ea<<' '<<eb<<'\n';
  27.     }else{
  28.       ea = va[i];
  29.       eb = vb[i]-te;
  30.       cout<<"B "<<ea<<' '<<eb<<'\n';
  31.     }
  32.     ta += ea;
  33.     tb += eb;
  34.   }
  35.   e = abs(ta-tb);
  36.   e /= t;
  37.   printf("%.10Lf", e);
  38.   return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement