SHARE
TWEET

Untitled

a guest Nov 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int M = 3e5 + 10;
  5.  
  6. long long res[M], cAcc[M];
  7. int pts[M];
  8.  
  9. struct Bucket {
  10.     long long acc = 0;
  11.     int rank = 0, time = 0;
  12.  
  13.     void inc(int t) {
  14.         acc += 1ll * (t - time) * rank;
  15.         time = t;
  16.         rank++;
  17.     }
  18.  
  19.     long long getAcc(int t) {
  20.         return acc + 1ll * (t - time) * rank;
  21.     }
  22. } b[M];
  23.  
  24.  
  25. int main() {
  26.     int nc, nw;
  27.     scanf("%d %d", &nc, &nw);
  28.     for (int t = 0; t < nw; t++) {
  29.         int k;
  30.         scanf("%d", &k);
  31.         while (k--) {
  32.             int c;
  33.             scanf("%d", &c);
  34.             c--;
  35.             res[c] += b[pts[c]].getAcc(t) - cAcc[c];
  36.             b[pts[c]++].inc(t);
  37.             cAcc[c] = b[pts[c]].getAcc(t);
  38.         }
  39.     }
  40.  
  41.     for (int i = 0; i < nc; i++) res[i] += b[pts[i]].getAcc(nw) - cAcc[i];
  42.     for (int i = 0; i < nc; i++) printf("%.9lf\n", 1 + 1. * res[i] / nw);
  43.     return 0;
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top