SHARE
TWEET

Untitled

a guest Feb 27th, 2020 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define DAU std::ios::sync_with_stdio(false); fin.tie(0); fout.tie(0);
  3. #define PLEC fin.close(); fout.close(); return 0;
  4. using namespace std;
  5. using ll = long long;
  6. ifstream fin("ou.in");
  7. ofstream fout("ou.out");
  8. vector<ll> v, p;
  9. ll rez;
  10. int n, nrc, nrt, x, y;
  11. int main()
  12. {
  13.     DAU
  14.     fin >> n;
  15.     v = p = vector<ll>(n + 2);
  16.     for (int i = 1; i <= n; ++i)
  17.     {
  18.         fin >> x;
  19.         nrc = min(n - i, i - 1);
  20.         nrt = 2 * nrc;
  21.         nrt = min(x - x % 2, nrt);
  22.         nrc = nrt / 2;
  23.         if (nrc)
  24.         {
  25.             p[i] = x % nrt;
  26.             y = x / nrt;
  27.             v[i - nrc] += y;
  28.             v[i] -= y;
  29.             v[i + 1] += y;
  30.             v[i + nrc + 1] -= y;
  31.         }
  32.         else p[i] = x;
  33.     }
  34.     v[0] = 0;
  35.     for (int i = 1; i <= n; ++i)
  36.     {
  37.         v[i] += v[i-1];
  38.         rez = v[i] + p[i];
  39.         fout << rez << ' ';
  40.     }
  41.     PLEC
  42. }
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