QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#934014#9534. 运筹帷幄 / 《十字神名的预言者》理解(色彩)guosoun100 ✓1112ms808028kbC++175.4kb2025-03-14 13:27:122025-03-14 13:27:12

Judging History

This is the latest submission verdict.

  • [2025-03-14 13:27:12]
  • Judged
  • Verdict: 100
  • Time: 1112ms
  • Memory: 808028kb
  • [2025-03-14 13:27:12]
  • Submitted

answer

#include <bits/stdc++.h>

template <class T>
int S(T &c) {
  return c.size();
}
template <class T>
using V = std::vector<T>;
using ll = long long;

struct slice {
  V<ll> *a, *b;
  int l, r;
  ll d;
  int pop_back(int k, auto f) {
    if (r > l) {
      for (int i = std::__lg(r - l); ~i; i--)
        if (r - (1 << i) >= l && (*a)[r - (1 << i)] + d - k + f(r - (1 << i) - l) < 0) r -= 1 << i;
    }
    while ((*a)[r] + d - k + f(r - l) < 0) assert(r > l), --r;
    ll t = std::min<ll>((*a)[r] + d, k - f(r - l + 1));
    d -= t;
    return t;
  }
  ll front() { return (*a)[l] + d; }
  ll sum() { return (*b)[l] - (*b)[r + 1] + (r - l + 1) * d; }
};

struct luck {
  V<ll> a, b;
  ll d, p, q, s;
  V<std::pair<ll *, ll>> stk;
  luck() : d(0), p(0), q(0) {}
  luck(int n, int p) : a(n), b(n + 1), d(0), p(p), q(n) {}
  void add(const luck &o, ll sgn) {
    stk.emplace_back(&q, q);
    for (int i = o.p; i < o.q; i++) {
      stk.emplace_back(&a[i - o.p + p], a[i - o.p + p]);
      if (i - o.p + p == q)
        a[q++] = -d + (o.a[i] + o.d) * sgn;
      else
        a[i - o.p + p] += (o.a[i] + o.d) * sgn;
    }
    for (int i = o.q - o.p + p - 1; i >= p; i--) {
      stk.emplace_back(&b[i], b[i]);
      b[i] = b[i + 1] + a[i];
    }
  }
  void push_front(ll v) {
    stk.emplace_back(&p, p);
    stk.emplace_back(&a[p - 1], a[p - 1]);
    stk.emplace_back(&b[p - 1], b[p - 1]);
    a[p - 1] = a[p] + v;
    b[p - 1] = b[p] + a[p - 1];
    --p;
  }
  void pop_back(ll k) {
    stk.emplace_back(&q, q);
    stk.emplace_back(&d, d);
    d -= k;
    if (p == q) return;
    for (int i = std::__lg(q - p); ~i; i--)
      if (q - (1 << i) > p && a[q - (1 << i)] + d < 0) q -= 1 << i;
  }
  void undo(int k) {
    while (S(stk) > k) {
      auto [a, b] = stk.back();
      *a = b, stk.pop_back();
    }
  }
  std::pair<luck, slice> split(int s) {
    luck re(s, 0);
    for (int i = 0; i < s; i++) {
      if (p + i < q) re.a[i] = a[p + i] + d;
      if (p + s < q) re.a[i] -= a[p + s] + d;
    }
    slice t = {&a, &b, (int)p + s, (int)q - 1, d};
    return std::make_pair(re, t);
  }
  ll operator[](int x) { return p + x < q ? a[p + x] + d : 0; }
};

int main() {
  std::cin.tie(0)->sync_with_stdio(0);
  int n;
  std::cin >> n;
  V<int> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; i++) std::cin >> a[i];
  for (int i = 1; i <= n; i++) std::cin >> b[i];
  V<V<int>> g(n + 1);
  for (int i = 1; i < n; i++) {
    int u, v;
    std::cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  V<int> son(n + 1), siz(n + 1), dep(n + 1), tp(n + 1), fa(n + 1), bk(n + 1);
  V<luck> c(n + 1);
  auto dfs1 = [&](auto &self, int u, int ff) -> void {
    siz[u] = 1, fa[u] = ff, dep[u] = dep[ff] + 1;
    for (int v : g[u])
      if (v != ff) {
        self(self, v, u);
        siz[u] += siz[v];
        son[u] = siz[v] > siz[son[u]] ? v : son[u];
      }
  };
  auto dfs2 = [&](auto &self, int u, int t) -> void {
    tp[u] = t;
    if (son[u]) self(self, son[u], t);
    if (!son[u]) {
      c[tp[u]] = luck(siz[tp[u]] + 1, dep[u] - dep[tp[u]] + 1);
    }
    bk[u] = S(c[tp[u]].stk);
    for (int v : g[u])
      if (v != fa[u] && v != son[u]) {
        self(self, v, v);
        c[tp[u]].add(c[v], 1);
      }
    c[tp[u]].push_front(a[u]);
    c[tp[u]].pop_back(a[u] - b[u]);
  };
  V<ll> ans(n + 1);
  using info = std::pair<std::deque<std::pair<int, slice>>, luck>;
  auto push_front = [&](info &o, int k) {
    o.second.push_front(k);
    for (auto &[a, b] : o.first) a += 1;
  };
  auto pop_back = [&](info &o, int k) {
    auto &[ve, f] = o;
    int tk = 0, bk = k;
    while (ve.size() && f[ve.back().first] + ve.back().second.front() <= k) {
      tk += ve.back().second.front(), k -= ve.back().second.front();
      ve.pop_back();
    }
    if (ve.size()) {
      if (f[ve.back().first + ve.back().second.r - ve.back().second.l + 1] < k)
        tk += ve.back().second.pop_back(k, [&](int i) {
          return f[i + ve.back().first];
        });
    }
    f.pop_back(bk - tk);
  };
  auto calc = [&](info &o) {
    ll ans = 0;
    auto &[ve, f] = o;
    ans += f.b[f.p + 1] - f.b[f.q] + (f.q - f.p - 1) * f.d;
    for (auto [d, s] : ve) ans += (d - 1) * s.front() + s.sum();
    return ans;
  };
  auto dfs3 = [&](auto &self, int u, info &o) -> void {
    auto &[ve, f] = o;
    auto bve = ve;
    int vid = S(f.stk);
    c[tp[u]].undo(bk[u]);
    for (int v : g[u])
      if (v != fa[u] && v != son[u]) f.add(c[tp[v]], 1);
    ve.emplace_front(0, c[tp[u]].split(0).second);
    int tvid = S(f.stk);
    push_front(o, a[u]);
    pop_back(o, a[u] - b[u]);
    ans[u] = calc(o);
    f.undo(tvid);
    ve = bve;
    for (int v : g[u])
      if (v != fa[u] && v != son[u]) {
        int vid = S(f.stk);
        auto bve = ve;
        auto [ta, tb] = c[tp[u]].split(siz[v]);
        f.add(c[tp[v]], -1);
        f.add(ta, 1);
        if (tb.l <= tb.r) ve.emplace_front(siz[v], tb);
        push_front(o, a[u]);
        pop_back(o, a[u] - b[u]);
        self(self, v, o);
        f.undo(vid);
        ve = bve;
      }
    push_front(o, a[u]);
    pop_back(o, a[u] - b[u]);
    if (son[u]) 
      self(self, son[u], o);
    f.undo(vid);
    ve = bve;
  };
  dfs1(dfs1, 1, 0);
  dfs2(dfs2, 1, 1);
  info o = {{}, luck(2 * n, n)};
  dfs3(dfs3, 1, o);
  for (int i = 1; i <= n; i++) std::cout << ans[i] << ' ';
  std::cout << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 407ms
memory: 279532kb

input:

500000
2917354 8624102 3036763 6694181 1960946 1561749 446540 6542253 4404148 4165628 4282907 4466931 6755755 8550798 8939212 8718942 3728996 5384016 1001578 9678850 7863737 615178 4542709 5630910 1648924 7786530 6062412 1166998 845267 7333983 761083 8940973 9233991 3478232 3488633 4370634 3370299 7...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Test #2:

score: 1
Accepted
time: 474ms
memory: 243048kb

input:

500000
1432911 9218012 526599 5663965 7753968 8682485 9616147 6418968 7005438 2733164 1942342 2555702 2105211 4155211 4574052 3296987 244073 9585282 5587755 5364376 9703961 7605269 4978598 9005431 4281543 2700429 7052623 7918906 4395548 3780935 9816779 7501004 1813246 8652533 9436864 7108288 9927814...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Subtask #2:

score: 5
Accepted

Test #3:

score: 5
Accepted
time: 1ms
memory: 4964kb

input:

2000
1162428 8643028 249125 7742502 7419912 503896 8081798 2949025 3959763 6068565 9473220 5470222 4868883 3831741 100937 1037765 7595766 3666553 4764082 9151922 955563 3281471 6307042 8986583 8798862 2373235 6407272 2332263 7907716 5326232 9227029 4131238 2968973 8484670 5729644 7952190 4312011 445...

output:

729227469581 732213458900 737010258646 724696537313 720858937605 733961660724 741825171738 745895101729 738120812420 737629098426 744011186024 749436630498 748878941550 716254721039 742509368062 742422166722 719106427233 741921147514 745820602036 741512493937 753661315016 753586735998 712257054907 7...

result:

ok single line: '729227469581 732213458900 7370...1075 804392670995 795314575266 '

Test #4:

score: 5
Accepted
time: 1ms
memory: 4544kb

input:

2000
7888898 9046517 5578882 4955786 3535714 7146944 5316229 6339394 8596056 4364255 7816901 7850250 9160246 1336902 1148662 7937195 9146492 8119349 1932198 1388652 3987526 3631639 308271 280711 2617455 4434228 9493251 260755 5159703 2190441 2734004 5687610 425973 5651131 6061837 6650259 635450 4142...

output:

192916661089 190247858537 195692442520 198662256320 197493368501 194721984765 200585535500 202842895887 197876855917 205351913626 199271595420 202357319603 203896903013 202861512875 207619571012 208401116657 195133491681 202435724192 207805550277 202923760123 205468886674 200758437348 210549216046 2...

result:

ok single line: '192916661089 190247858537 1956...4583 329564264282 314793426492 '

Test #5:

score: 5
Accepted
time: 0ms
memory: 4544kb

input:

2000
8729279 3895728 5950102 7097753 6466309 5353433 3934874 2733816 4312855 3400636 1932712 7368072 3086579 3483481 4850661 3322298 745733 7095311 3533978 2712314 1478216 1598032 7873601 309630 6619778 4870186 8582378 6384832 6659045 5538271 6026093 9153299 7669513 4230019 7388902 6424017 3441081 4...

output:

29189444141 31637155037 34240974052 30891572838 32710498028 34425995841 36561374971 37726650339 35522906251 34641022915 32787430238 39066948386 33655355686 38952765016 36766772619 35784056589 38782283439 39397691342 38023789921 44398395987 43151695227 38722381193 41059976536 45790504587 35053877327 ...

result:

ok single line: '29189444141 31637155037 342409...981760 46707141771 75908932293 '

Subtask #3:

score: 11
Accepted

Dependency #2:

100%
Accepted

Test #6:

score: 11
Accepted
time: 8ms
memory: 8576kb

input:

8000
14410 8026167 5821985 6197768 4846754 5502186 457223 4138402 1065369 6274711 3273479 6037429 1880916 9203480 1118321 7384144 7273159 4935649 7567003 5840595 8814425 3010184 381890 4753846 6610518 2297253 8733528 813603 9800155 1347301 7974924 7153941 3033995 7099075 7802358 7941527 3811372 4515...

output:

12912196548807 12891974798797 12908925510961 12911180455243 12929760464746 12876993745667 12932428886065 12862675870200 12896740056345 12925407381734 12943839857598 12941233598405 12844127763611 12874615731906 12864247929524 12949012743098 12963886312990 12878792716399 12888463196238 12962192470224 ...

result:

ok single line: '12912196548807 12891974798797 ... 12573096997986 12568547879739 '

Test #7:

score: 11
Accepted
time: 8ms
memory: 7552kb

input:

8000
5334846 4092403 4501048 349997 6928946 3782789 364982 4632317 2119399 806385 8439296 5564150 4904743 384649 4855724 9303949 1586769 7658292 3762535 5685943 3481561 5028965 4993082 2341581 148177 6619433 8060655 6499241 4642703 5559232 5726433 9342900 9962997 5961779 5592131 5587821 8402035 7560...

output:

3124169948060 3143500678613 3143886221441 3105340380331 3162762190874 3143766411197 3163810328106 3089905584615 3074799075288 3125270068508 3108122799690 3093543395807 3162869879580 3125188647455 3182733928221 3143689812139 3094688452179 3121183544896 3163443240751 3094348742097 3143048426921 309316...

result:

ok single line: '3124169948060 3143500678613 31...26 3765940366336 3836408234344 '

Test #8:

score: 11
Accepted
time: 9ms
memory: 7808kb

input:

8000
4625419 9112801 5976723 689883 8235653 160377 3672932 837844 5338397 4813070 803924 721905 8225977 6447778 8171708 4200254 6928607 7231291 2506458 8999248 6203597 5100594 6200868 1536599 3700427 23396 6813411 7164111 8184729 341730 4325060 3372174 6661194 6269754 3783509 9822745 3386948 5696675...

output:

135296527247 140282119436 155894491611 140801712233 153180210347 150166959528 151175293428 156127400658 172710089842 175401783119 154221435554 173372354356 169618836621 167334918415 192328762578 169524084491 185076943994 169999267104 188716188095 169028070593 159013963236 159201315421 173323572939 1...

result:

ok single line: '135296527247 140282119436 1558...1217 330752185758 251252812015 '

Test #9:

score: 11
Accepted
time: 7ms
memory: 8064kb

input:

8000
10000000 10 4 1 3 2 5 10 9 8 6 2 6 1 6 2 5 3 4 8 3 8 8 6 4 3 5 8 9 5 10 10 4 10 7 2 5 8 1 8 6 5 8 7 9 2 1 4 7 8 7 1 10 6 8 7 9 7 5 9 10 9 4 7 1 5 5 7 7 5 6 6 5 9 2 2 6 8 8 5 4 6 3 8 8 7 3 5 8 1 6 10 1 1 8 3 7 6 10 7 9 10 6 1 9 4 5 4 9 4 3 3 6 1 6 7 9 4 4 2 5 6 6 3 4 2 5 6 8 2 2 6 8 6 1 6 4 4 10...

output:

0 52374 28847 73365 73408 68855 88291 49930 72680 71900 49699 94477 93465 33501 94384 74158 94513 49831 116341 94156 71507 107877 71010 129571 55243 93014 115333 53789 71602 116348 73419 114706 114698 94621 87904 53151 71465 116381 129422 107991 74133 22063 129825 22453 95928 114958 50825 74338 1162...

result:

ok single line: '0 52374 28847 73365 73408 6885... 21986 21982 21982 21991 21987 '

Subtask #4:

score: 3
Accepted

Test #10:

score: 3
Accepted
time: 406ms
memory: 808024kb

input:

500000
3510958 555748 1755276 8052590 2637508 6738483 3902556 5908218 2771751 101426 2521991 4600125 3689071 5967161 4691119 1576283 3016668 1390228 4136191 280627 416608 1308186 8670123 4688527 1739055 8194608 5899848 8540886 4788549 1713420 4222198 1140410 6467624 4959165 8417413 8242423 4238740 7...

output:

155973158294218106 155972671649632031 155971543850811152 155970395034419804 155971148911112743 155970458197243193 155970888074795388 155969709640741338 155969672402132680 155968839639831118 155967606830081256 155966368992243704 155965186603554567 155964553558273567 155964501477240261 155964051128655...

result:

ok single line: '155973158294218106 15597267164...56882260375 155847979543968497 '

Test #11:

score: 3
Accepted
time: 404ms
memory: 808028kb

input:

500000
6862245 2075671 8827273 3581053 9272779 1217225 9096780 9265696 1156535 5753554 1122298 7002703 3103618 5851341 4355797 1380483 2681916 5632160 4116433 8172670 8410367 8843284 3055828 2849086 3872063 1799034 7247325 2747885 5453746 9046863 7334947 6216742 6096179 9516754 8760065 859217 741465...

output:

156732845075420434 156732931938105248 156731837058998993 156732245574976080 156731379985998280 156731136676600895 156730043734117042 156729055295537413 156728387617114479 156727206106102730 156726764049855155 156725645414155234 156725907438865052 156724689617402851 156724656804803203 156724245876743...

result:

ok single line: '156732845075420434 15673293193...17828018823 156204089434788831 '

Subtask #5:

score: 3
Accepted

Test #12:

score: 3
Accepted
time: 430ms
memory: 317524kb

input:

500000
1447354 6239936 3320890 2751233 6778720 8222961 9129509 4314978 997318 5537644 5933866 8995314 9777484 7307667 4952512 7093075 6861898 5158953 7199915 1603387 3208622 6680258 7814056 3474161 1387472 5210270 7818944 4384030 2183484 5468991 9119372 6674396 7637608 5155971 2564722 4381384 201363...

output:

1250066290808 2500121549098 2500127387190 2500128526504 2500120471530 2500117583048 2500115769952 2500125399014 2500132034334 2500122953682 2500122161238 2500116038342 2500114474002 2500119413636 2500124123946 2500119842820 2500120305174 2500123711064 2500119629140 2500130822196 2500127611726 250012...

result:

ok single line: '1250066290808 2500121549098 25...84 2500133390408 2500117402432 '

Test #13:

score: 3
Accepted
time: 417ms
memory: 325540kb

input:

500000
10000000 2 4 4 4 4 3 2 1 1 1 2 1 5 4 5 5 3 1 5 4 1 2 4 3 3 4 2 4 1 5 1 3 2 2 2 1 1 2 3 2 3 3 3 1 3 5 2 5 3 5 1 4 3 4 1 5 1 4 5 5 5 1 3 5 3 2 2 1 2 2 2 4 1 2 1 2 1 3 5 1 1 1 5 2 2 1 1 4 4 2 5 1 5 5 2 1 3 3 1 3 5 5 4 5 3 3 5 3 3 5 4 1 5 3 3 2 3 5 4 4 4 3 4 2 4 5 5 3 3 4 2 4 5 5 1 2 5 2 1 2 2 3 ...

output:

0 750824 750822 750822 750822 750822 750823 750824 750825 750825 750825 750824 750825 750821 750822 750821 750821 750823 750825 750821 750822 750825 750824 750822 750823 750823 750822 750824 750822 750825 750821 750825 750823 750824 750824 750824 750825 750825 750824 750823 750824 750823 750823 7508...

result:

ok single line: '0 750824 750822 750822 750822 ...22 750821 750822 750824 750825 '

Subtask #6:

score: 6
Accepted

Test #14:

score: 6
Accepted
time: 1020ms
memory: 274888kb

input:

500000
5818678 225993 5217749 99270 4664588 2463513 1808294 5626921 1635290 1083470 1979005 2454173 8016280 2399951 5465711 4433499 1307917 3107368 85904 3588173 9379529 8123738 109998 467095 6602517 4636566 783296 183760 871054 7932001 4143391 3035085 4781041 1494096 5017416 8492947 5212464 9893044...

output:

14320679860420 14126575083625 14872169427515 14333882450170 15544715795730 15329768143897 16037034952469 15710805540716 15201943981080 15344787078426 15956518721096 16287339349663 15290193897837 17396975710032 16576777036669 16921154084989 15421931892089 16467270884462 17129983868201 15413486257427 ...

result:

ok single line: '14320679860420 14126575083625 ... 27145999181389 33958720140651 '

Test #15:

score: 6
Accepted
time: 1005ms
memory: 275396kb

input:

500000
939904 8509411 614195 8727511 9364177 986719 9702145 2495202 3575847 979921 7856386 2605957 3181468 2660345 3870326 6478479 5371706 911143 1560365 4634288 38176 3790699 6804998 4717557 1087787 8761799 8957639 8099186 327280 6741184 9803823 7685793 4536036 5092560 6021059 4655801 5001159 51651...

output:

14350319418795 14436562435938 15103389897464 15309718137692 15576685337983 16320687346480 16060084813869 17296191287679 16233223919733 17078404821838 15275091978460 16341595253612 16521400549535 17420660549868 18551045312163 15090273765762 18109576920020 15914642239437 16831394969740 16453451969729 ...

result:

ok single line: '14350319418795 14436562435938 ... 22955495898300 26182675241815 '

Subtask #7:

score: 16
Accepted

Test #16:

score: 16
Accepted
time: 474ms
memory: 343276kb

input:

500000
3 2 4 5 4 5 2 3 3 2 4 5 3 3 2 4 1 3 4 3 5 4 2 1 5 4 3 3 3 1 4 1 1 4 2 4 3 1 3 5 1 1 2 4 4 3 1 2 2 4 3 5 3 4 3 5 2 5 1 1 1 2 2 5 2 3 4 4 3 1 3 5 4 4 2 1 2 2 2 1 3 1 2 5 3 5 2 3 3 5 5 3 1 2 4 1 4 3 2 3 1 2 2 5 2 5 3 4 4 2 5 2 4 3 4 3 4 2 4 1 3 3 4 1 4 2 5 4 4 5 4 1 3 4 4 2 1 3 4 1 2 1 5 1 4 1 1...

output:

28894347732 28893596793 28894347718 28894944437 28894039303 28894944437 28893000090 28894270625 28894558921 28893751031 28892326299 28893596807 28891652520 28892249251 28892403431 28893077236 28894944460 28893000136 28894347744 28893673969 28891055903 28892403441 28893751073 28890382197 28893751065 ...

result:

ok single line: '28894347732 28893596793 288943...695756 29020464208 29021060741 '

Test #17:

score: 16
Accepted
time: 516ms
memory: 264584kb

input:

500000
4 2 5 3 3 2 3 2 5 4 5 5 1 1 5 1 2 4 3 2 5 5 1 4 3 3 2 5 1 2 2 5 5 2 4 4 2 4 4 4 5 5 5 2 2 2 2 4 4 3 4 4 3 5 5 2 5 1 1 5 3 2 4 2 5 5 2 5 4 4 5 2 5 5 1 5 4 1 3 2 5 3 5 4 1 1 5 1 4 2 1 4 1 2 5 2 3 2 3 3 4 4 5 4 5 3 2 5 2 4 3 4 4 3 2 1 4 1 4 2 2 5 2 3 5 1 5 2 1 4 5 2 4 1 1 1 3 5 3 1 4 4 1 3 5 5 1...

output:

7052278697 7052990721 7051547902 7050873562 7053028363 7050180816 7049450518 7053028349 7053009533 7050892846 7051566764 7053665097 7050930438 7051680064 7051547944 7051623228 7051622816 7052316430 7052259972 7048701488 7052429712 7053778011 7053740383 7053702743 7051642468 7054471209 7052335258 704...

result:

ok single line: '7052278697 7052990721 70515479...07546472 7106031320 7106686513 '

Test #18:

score: 16
Accepted
time: 965ms
memory: 277208kb

input:

500000
3 2 1 3 1 3 5 2 5 5 3 4 5 4 3 2 3 1 5 1 2 3 2 5 1 3 2 4 2 5 1 1 2 5 3 4 1 2 5 5 1 1 1 1 1 3 4 2 2 3 4 5 5 2 4 5 1 4 5 1 1 1 2 2 2 5 5 4 5 5 3 2 4 2 4 2 1 3 4 3 3 4 4 1 2 5 4 2 1 4 2 3 2 1 3 5 5 5 4 5 5 3 1 1 5 3 4 2 1 5 2 2 3 2 4 3 5 3 2 3 5 2 1 3 2 4 3 3 1 3 4 2 4 1 5 4 2 4 2 2 4 5 1 4 4 4 2...

output:

9024580 8428329 8894401 8789383 8739611 9024717 9228371 9511697 9668149 9552601 9685626 9466159 10285511 9270033 9135495 10944741 10998293 9711446 9853881 10010430 10513955 10235879 10317439 9681907 10563705 9515853 10237165 10342431 11607903 9517328 10339557 11021991 10972755 10195434 11761909 1098...

result:

ok single line: '9024580 8428329 8894401 878938...304 15522231 18555159 19831672 '

Subtask #8:

score: 22
Accepted

Dependency #3:

100%
Accepted

Test #19:

score: 22
Accepted
time: 47ms
memory: 37856kb

input:

50000
1776777 1501460 4335211 9431727 1408153 1778905 1547822 5087567 1882771 8539176 5340351 7039722 3339098 1620435 7075972 9178237 7926119 7094874 6261072 9638868 7085915 6597289 5026801 893179 3692295 6798079 3340534 5254173 6419557 9260757 3468118 2735542 320896 313035 5358475 944841 4021760 54...

output:

485463981014897 485585404899364 485556663084403 485627897915885 485349762312233 485708983374941 485225488457651 485668943284919 485677812752881 485769629285073 485461131918927 485658106495146 485105149015600 485786273458983 485867291162037 485767877072577 485784951480033 485867887127908 485960383625...

result:

ok single line: '485463981014897 48558540489936...82241549427909 482501161744561 '

Test #20:

score: 22
Accepted
time: 48ms
memory: 28988kb

input:

50000
1674077 172512 214218 4219171 3481735 5250244 627837 9973771 5046659 7156995 5128340 3474283 9133082 422836 4056214 9529226 4153942 2768682 5660269 4628792 5137815 716254 4242484 8701505 5125468 790298 4594036 2817179 6744824 7310859 515172 2564008 8647031 7944975 3669336 9907051 6841536 64495...

output:

118842135801120 118967288010922 118967299975073 118717812916386 118842472447140 119085061192487 118599011422518 118712665560044 118833461361319 118827178028831 118832951418522 118963177414363 118937123324161 118956219542094 118954294214371 119073370806316 119196841149947 119318484042345 118720999597...

result:

ok single line: '118842135801120 11896728801092...24118060789577 123565846098141 '

Test #21:

score: 22
Accepted
time: 71ms
memory: 29436kb

input:

50000
5341517 2546120 1401021 1292382 7436475 144762 8497031 9880836 3916625 9522801 3421062 7502267 4874566 1787955 4520571 293417 9682751 7338509 6342133 6269635 4918052 2955850 9611943 2879761 5537546 8108070 9344381 4994597 8809774 7099368 2545467 8453154 5982965 7152497 1392548 7208358 6466121 ...

output:

1231879526871 1329532218616 1169718771620 1245511268973 1331672844481 1338878960306 1185902416125 1433341288701 1352111386937 1261904329281 1556859479956 1268728014258 1462287084285 1355578226748 1361568933864 1453276434577 1539541176389 1301442719312 1284567576769 1436015814241 1461328575943 140143...

result:

ok single line: '1231879526871 1329532218616 11...45 2266843001249 2788929000068 '

Test #22:

score: 22
Accepted
time: 60ms
memory: 47024kb

input:

50000
5979436 7383260 3699850 3741295 9493394 5392411 7802316 8829092 228332 1336865 5962409 4728244 7783573 9965976 7651642 1210158 8070211 7028581 9659176 2489761 9271916 2729206 9973969 2750305 3202325 5737422 6066679 8107390 7393579 4997295 1842851 6481487 2455707 3626030 7517349 1552531 4371997...

output:

259759612443678 259796678733572 259838327899891 259858554747427 259885531148751 259923893780192 259967143148320 260003091572737 260003006935447 260003385772051 260004209826149 260015209042653 260046359223695 260072517691075 260151901853627 260202717978734 260206311028252 260250141591996 260261438838...

result:

ok single line: '259759612443678 25979667873357...59973986429849 259974693163829 '

Test #23:

score: 22
Accepted
time: 51ms
memory: 33472kb

input:

50000
10000000 4 1 6 5 6 7 6 1 9 10 4 5 5 5 3 3 6 5 3 9 6 2 1 9 6 2 6 3 7 6 2 6 10 8 1 1 2 8 5 10 10 2 6 5 9 4 8 9 7 8 3 6 9 2 6 8 9 2 8 3 6 3 5 3 6 2 8 1 2 4 6 3 1 7 2 9 1 9 7 5 9 7 9 1 8 10 5 4 1 1 10 1 2 2 3 8 5 4 1 9 7 9 2 6 6 9 8 4 8 9 3 7 8 7 7 9 1 10 10 5 3 5 5 2 9 5 3 3 10 7 9 8 8 8 3 8 2 2 ...

output:

0 189093 319996 437093 237649 574158 348130 516104 480923 621713 163681 729094 473879 297721 839317 372118 956772 301044 569486 864348 148888 324068 483937 999604 703747 610198 1075321 607077 433588 616120 459249 627961 483295 751098 569842 1196642 1136248 1273265 374247 323320 763988 876593 283359 ...

result:

ok single line: '0 189093 319996 437093 237649 ...06 137809 137808 137807 137810 '

Subtask #9:

score: 16
Accepted

Dependency #8:

100%
Accepted

Test #24:

score: 16
Accepted
time: 93ms
memory: 72868kb

input:

100000
41795 5055757 3617408 2610489 8944804 7922915 4668278 5716553 6563479 6477533 1331920 6597905 4418831 9555983 7758948 8295194 5175364 6981521 7068034 606962 604402 2071302 9694392 93610 7720268 1851765 5395356 1992679 5686385 5893311 7282183 8275339 5608191 7029834 8601497 6214712 5138331 518...

output:

1913201591326498 1912952362712153 1913437322835085 1913188330200278 1913141257915546 1913609951869206 1912728203079746 1913843227554155 1912949980051035 1913154330650354 1913194036846748 1912520865608451 1913384177330379 1912692775582398 1912901993394981 1913843030869117 1913364365598461 19133493425...

result:

ok single line: '1913201591326498 1912952362712...7486005860722 1918064383390622 '

Test #25:

score: 16
Accepted
time: 101ms
memory: 54040kb

input:

100000
9869998 4927921 6051560 6347483 3804361 9097528 7090707 7099037 2501910 6726893 728401 9734908 3527189 3860039 5856987 2754559 6858362 9912929 1108336 1099968 5511311 5473363 9375434 602105 8204717 1453152 2784571 6880 1517287 685996 1107698 2616808 3543010 1547148 7665574 6221123 5598851 647...

output:

466839202224316 467073270945439 467085715366807 466617829508681 467311710916104 467317363549054 466375419826870 466851475226788 466148483260499 467313406190019 467086494580704 467547830565131 466396056442514 467790759459270 467544409209583 466863107279871 466630881108085 466620003476637 467110941514...

result:

ok single line: '466839202224316 46707327094543...80104716640928 481323642697447 '

Test #26:

score: 16
Accepted
time: 132ms
memory: 56300kb

input:

100000
8018355 2772875 1095356 3199887 9337611 9755780 6567887 3882179 133716 9480364 1208282 2928954 6001122 518533 7561438 6051208 8033253 1896114 9751266 4637666 5459251 2344423 8594599 1793024 4527182 7771222 4919463 6152434 2650418 5784388 9385571 1321497 1878924 2493074 1095389 2390404 5401389...

output:

2457534706132 2651738133597 2647310768600 2854848161008 2356648050329 2567368721850 2423819650142 2578151735405 2543829414779 2723563743884 2586012915644 2750676984370 2549980857156 3101357140696 2940308047543 2820983724692 2790244775876 2584421059162 2875622288125 2942446373761 2819341260596 281933...

result:

ok single line: '2457534706132 2651738133597 26...72 5311505837266 5152678676102 '

Test #27:

score: 16
Accepted
time: 133ms
memory: 86480kb

input:

100000
8314543 8414761 4495965 2973818 803806 335256 6875756 3831350 2072685 8077052 6491759 385836 8432309 2368197 6228285 8501006 8917142 7209009 5077044 5336748 4836692 2780887 5326549 9159594 2349935 7697033 3033615 3336665 9019361 8349441 8797154 1348066 9927157 2602548 7453701 1539522 9041844 ...

output:

1055454956927247 1055500501630982 1055629461741095 1055639063952826 1055670949795719 1055675172535502 1055677063775445 1055746235418044 1055746134255527 1055750874276836 1055785047584126 1055853113651880 1055854104485589 1055935829962965 1055937117591852 1056013111791173 1056042541064276 10561334717...

result:

ok single line: '1055454956927247 1055500501630...9200027032830 1055833465746560 '

Test #28:

score: 16
Accepted
time: 111ms
memory: 64096kb

input:

100000
10000000 6 9 2 8 7 4 1 10 1 3 8 8 3 9 4 4 1 9 1 2 9 1 1 6 5 5 8 3 3 7 7 1 10 7 7 2 3 1 3 5 4 4 4 10 10 8 2 5 8 3 5 8 3 9 5 10 8 6 1 1 5 2 7 2 4 10 8 5 9 8 7 3 6 7 9 2 7 9 7 2 10 3 5 6 6 3 10 1 9 6 8 9 8 5 6 10 8 5 4 4 8 7 5 10 10 5 2 7 8 6 3 3 2 6 3 10 7 1 4 8 10 3 2 4 4 7 6 5 5 7 6 3 6 2 4 2...

output:

0 685905 280109 870327 290293 1084294 958383 280212 767738 956533 355347 1359721 950710 1349602 1195136 1332714 1128928 1134208 1346382 1169616 1037717 1446316 622377 1031622 1297160 1614900 1414280 1886160 1391771 1568138 1593155 1678244 1404838 1035333 278952 1688892 1225728 1424404 895395 1680022...

result:

ok single line: '0 685905 280109 870327 290293 ...17 275725 275725 275723 275723 '

Subtask #10:

score: 11
Accepted

Dependency #9:

100%
Accepted

Test #29:

score: 11
Accepted
time: 185ms
memory: 137980kb

input:

200000
2868472 6253818 6918710 6214812 6523513 2494532 2974021 221716 7083348 1662688 5446771 4059112 7868035 2131118 9570150 456118 2937070 8268295 6340493 8248647 6718752 3053060 8647442 7869579 1238449 602568 5764424 4142869 842206 4083434 9543793 7984233 4621863 8202712 596619 8516946 7685899 91...

output:

7658096754215394 7657629061723332 7657218586921731 7657983560689900 7656814349277684 7656367967718326 7658569223152384 7658595246463450 7657550679810204 7657695796708892 7655872249908208 7657192527089293 7655475885817176 7657644324840804 7657918059168727 7655969828279158 7657964974737158 76589298293...

result:

ok single line: '7658096754215394 7657629061723...8968967239457 7679435838777499 '

Test #30:

score: 11
Accepted
time: 206ms
memory: 105100kb

input:

200000
5650973 1727608 5470750 8242194 9278107 7911354 6399889 3775412 9513576 5024313 651698 3055254 8056208 3112329 8409502 3297468 5119001 6354571 8359614 9813078 5607475 235162 9480078 4741260 2501683 7515477 8570566 7530446 4658020 1694306 5170075 9120216 3990694 2199570 4812186 6352701 6580285...

output:

1903011810201740 1902512500220011 1902022242439049 1902521923420676 1902978272985730 1901540643109756 1902500953086344 1902984858526514 1902968553288866 1903449807438120 1903013881882484 1903002325184021 1903488429893146 1903495920846892 1903436714885602 1902511998255187 1901085076503125 19006169434...

result:

ok single line: '1903011810201740 1902512500220...5698834256354 1926261785639555 '

Test #31:

score: 11
Accepted
time: 329ms
memory: 113700kb

input:

200000
6796020 6170514 8474184 2707550 4916112 7834152 9877885 5759533 8966750 3086150 9475244 613251 1007718 3016347 4923154 5858971 4286552 6113070 9866595 5553923 8848807 9319059 2873024 2164054 730157 4639017 9353 5643040 7173089 4309040 8779315 1414325 9541442 9267605 5325975 3971549 3131446 42...

output:

5536793599571 5316647386268 5159078887517 5577010691428 5796697967220 5766003258104 6049009372943 5595813984388 5477526862225 5496801638320 6053445675304 5833133913235 6147044293818 6579883869746 6034870944878 5858190974624 6260339384950 5590040173177 6162284679394 6229733159437 6263716679612 667202...

result:

ok single line: '5536793599571 5316647386268 51...8 13061988703240 9978231968988 '

Test #32:

score: 11
Accepted
time: 283ms
memory: 165820kb

input:

200000
696281 1711508 7169602 1386846 4695457 5538738 5463856 8728083 2784390 3571971 8677317 2575522 3711042 7452786 7228987 2188020 9237812 3507849 9577757 2453227 846042 4574411 8571337 9851350 4037597 2062746 4836827 6473408 9478108 6871901 4629064 207872 2644105 6684965 6173866 7287329 4230442 ...

output:

4176259371803570 4176271497308609 4176293348944021 4176460609474410 4176464828617498 4176545633513335 4176564535911467 4176671654194531 4176912799458395 4176970187256323 4177078521261493 4177232685506723 4177289807244913 4177408057679923 4177626835956465 4177724786140515 4177760424900492 41777838375...

result:

ok single line: '4176259371803570 4176271497308...7612891293706 4177570901436300 '

Test #33:

score: 11
Accepted
time: 231ms
memory: 121148kb

input:

200000
10000000 5 10 5 9 1 7 2 9 1 5 7 10 2 1 9 8 4 6 10 5 2 10 3 4 7 6 9 3 3 1 10 10 9 5 3 1 2 6 1 8 10 3 3 3 5 2 8 4 6 5 6 4 10 6 10 2 1 3 10 5 5 10 1 9 7 2 3 4 10 6 8 1 9 7 2 4 2 5 3 7 6 2 4 8 2 4 6 5 3 6 2 9 4 3 8 10 3 3 6 3 9 7 8 3 6 3 5 7 1 3 10 1 8 8 4 2 2 7 1 8 3 8 5 5 6 3 7 9 5 8 1 2 7 10 6...

output:

0 869551 840319 667108 1190839 1984059 2312654 2704145 561293 3140233 2835178 1373775 2843314 2445196 3646421 3628731 3385864 1328477 2991992 3237095 1213611 1720117 1396742 1840059 3371054 2988070 1920267 2987068 2979119 3234578 3526125 3778421 2532564 4155464 1898849 4184559 2987564 4142235 236811...

result:

ok single line: '0 869551 840319 667108 1190839...26 549728 549722 549727 549722 '

Subtask #11:

score: 5
Accepted

Dependency #10:

100%
Accepted

Test #34:

score: 5
Accepted
time: 298ms
memory: 214668kb

input:

300000
8784325 4824260 5465358 6935419 4897541 4759881 7267073 7676207 5158639 9620562 5285645 6952917 7807111 4995591 5836279 5043231 407472 6920757 7091572 2654007 2713929 7663966 562895 2285747 9583349 556410 1355822 6756504 6426324 7817760 2112528 4826059 4987148 9621343 2801291 2706788 4049208 ...

output:

17264029454910559 17263647312268123 17264318158761557 17264980649377685 17264650632528375 17263091086980499 17264691017408315 17265462583377620 17265653884806549 17262376269244915 17263023778042168 17265191088220762 17263454408691499 17265661787613778 17266270063864169 17263070430634584 172631227807...

result:

ok single line: '17264029454910559 172636473122...630605875387 17322778491660607 '

Test #35:

score: 5
Accepted
time: 325ms
memory: 157860kb

input:

300000
3445269 1256251 8283258 3968299 5012436 181129 9748710 5007 5886021 341740 2440724 4313449 4974839 5779304 4170945 7658168 9997381 2010584 3805493 6154713 5367975 3681170 9302582 3049188 1062102 2097006 7318788 1114807 9395614 804360 2048483 1077956 2461552 7508130 603788 6169174 8312273 1239...

output:

4217018427164483 4216288302643738 4217675341496146 4217724610310800 4218408228512882 4219155488169811 4218343956246135 4215553298057867 4214808027462114 4216299481407349 4219083927852306 4217736617648382 4219124070838850 4218429828937061 4217765858759480 4219870096517756 4218454010757896 42191956105...

result:

ok single line: '4217018427164483 4216288302643...0558907316538 4272750113031447 '

Test #36:

score: 5
Accepted
time: 633ms
memory: 164028kb

input:

300000
7537298 8687758 7040389 6851977 6124979 2052774 7379439 1665657 8661518 2416555 7882739 2985317 3081420 3883893 9226583 5906985 9413569 4604776 1134922 7989509 9234231 3880772 2119568 9559381 4738661 3716135 944457 7021699 3342345 1367594 132440 3127665 370042 7647481 4893515 463112 7231279 5...

output:

8833158799147 8154702816436 8702466553971 8817397992951 9300706645428 8144522804045 9989492733922 8797564952671 8750711251072 8354436917414 10037782437824 8818259448266 9326864967216 10026047638755 8920766946861 9483766433311 9485398678276 9870396549699 9572226317902 9661606488333 8789366569065 1071...

result:

ok single line: '8833158799147 8154702816436 87... 15257245245030 16394370429241 '

Test #37:

score: 5
Accepted
time: 496ms
memory: 236604kb

input:

300000
5987011 9321916 3380253 2591607 5544051 9342635 1801706 9092220 2721673 8361538 4293985 6692786 3957486 9361664 1159854 3156368 1033908 7986142 8095316 5064621 3092244 6575587 4586030 7383536 1230701 7512736 1491310 8332318 8728773 5620845 2764338 3238104 1919373 5515485 5155665 5717020 33129...

output:

9317111941333279 9317194586586217 9317310190545625 9317361416525737 9317471325235584 9317588681962011 9317727237025294 9317799123943379 9318225654207183 9318309444634898 9318651866186026 9318819110188961 9318864266086151 9318947746314470 9319024079871348 9319039207781398 9319194259243413 93192216735...

result:

ok single line: '9317111941333279 9317194586586...2891835663724 9319982010269316 '

Test #38:

score: 5
Accepted
time: 385ms
memory: 181304kb

input:

300000
10000000 4 7 7 2 2 8 7 8 1 9 10 7 5 8 7 4 7 8 2 1 2 1 1 5 7 1 5 1 2 2 8 10 3 7 9 3 4 8 1 5 5 5 6 10 10 2 1 5 5 7 7 5 4 4 7 7 5 5 1 8 10 4 4 4 1 8 3 8 4 6 6 2 10 4 6 1 10 4 4 8 4 8 6 6 6 1 3 8 9 10 4 8 1 1 1 3 8 2 9 10 6 7 1 1 3 2 2 10 3 3 9 1 8 7 1 1 8 9 4 9 1 9 5 1 8 10 9 10 5 2 3 4 7 6 10 9...

output:

0 3644493 1615026 4026689 4409707 4814796 5566050 4408399 5416015 5183971 6159781 833117 6914277 2378698 5964846 5588594 7677531 4853727 8466907 2355541 9291523 1094713 6171517 1919786 3193164 6190784 5637828 6959513 1866168 6402390 4459344 7224954 6746912 3107482 1911711 5281753 7005306 6335324 528...

result:

ok single line: '0 3644493 1615026 4026689 4409...90 827190 827185 827191 827185 '

Subtask #12:

score: 1
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Dependency #11:

100%
Accepted

Test #39:

score: 1
Accepted
time: 493ms
memory: 337972kb

input:

500000
239070 1313393 6352050 82692 4118887 9129470 3763206 6368418 4005653 6134612 4719768 4968489 1983287 2665508 5750740 5003988 9562217 1444341 5212653 8577794 311573 4056768 395253 1944150 6477116 1918298 6598078 1935441 1855465 7633385 2655292 178721 690106 4205174 2430918 1382830 2891926 3816...

output:

47999655131294025 48000826796857901 48000722336313233 48001968936976039 47998407209839417 48000202996723264 48000752461096889 47999532724296986 48000792495838417 48001940599671579 48000746230155384 48000508913618998 48003133584448641 47997393910307233 47998605994808439 47999677105794871 480025564035...

result:

ok single line: '47999655131294025 480008267968...459229862332 48241638771955924 '

Test #40:

score: 1
Accepted
time: 509ms
memory: 263328kb

input:

500000
3026828 2272553 5513517 7808758 4984146 2817871 975843 8847984 2869513 3126177 9857349 5512112 7711707 4338068 6824780 8738710 3691144 6509274 6847505 9645565 9543039 1620545 861763 9964761 6220059 1915203 1945736 621485 3613010 4793931 7203397 6021303 9539092 4111994 4230983 4421234 5956012 ...

output:

11691190208758788 11692416935209576 11693608895805804 11689989034754152 11693574597592591 11694804552727023 11692435895043976 11693540568097225 11693632801615788 11691191485732052 11692358637927856 11691210078848458 11694687410263936 11694802018427329 11693551595735129 11692351971713002 116947810210...

result:

ok single line: '11691190208758788 116924169352...730690681586 11814054782818070 '

Test #41:

score: 1
Accepted
time: 1112ms
memory: 273052kb

input:

500000
4638127 8235116 724753 5341607 8436703 1928613 5272815 2498718 8311516 2573828 3473950 6811216 4309000 780002 8388342 6581143 1602930 9993781 8760230 8006013 127443 5361964 9549537 4352213 6497978 5496848 9890196 5124735 4868465 1202467 201658 8262703 2730167 9040435 1876009 1676455 5763039 7...

output:

16657777678407 15456677597417 16248524534880 14853011350068 15954957637832 15876389724934 15338952540408 15933343349052 15700346813976 16667788938704 17050268655118 16907424935290 16856112270831 17062094934055 17446221678409 18029354170133 17019862194902 18318879426182 19565768412420 18217265297612 ...

result:

ok single line: '16657777678407 15456677597417 ... 36453840414648 30942352045718 '

Test #42:

score: 1
Accepted
time: 863ms
memory: 389612kb

input:

500000
5715102 4578837 5702195 8817361 2386285 586032 6112989 4089112 2430540 741150 6164313 8890645 4036073 5768182 5357378 3690538 6143983 6731002 8131863 9708434 9582648 9433727 8969243 3350849 879298 3099570 53214 4963608 80702 4416061 6270824 2355246 1825147 5498075 3813935 1826870 1921197 8163...

output:

25966802217849484 25966815171003225 25967024156135002 25967493732795536 25967907163355934 25968085227106887 25968091312527470 25968254403872012 25968264588452015 25968378335520709 25968436525310064 25968727298575747 25968802706363038 25968994136821031 25969254216989273 25969519337058533 259696124423...

result:

ok single line: '25966802217849484 259668151710...497023428351 25968766327734159 '

Test #43:

score: 1
Accepted
time: 832ms
memory: 389484kb

input:

500000
5628896 9485303 6669322 5477074 6795630 6120227 618402 1540395 7802345 1004973 7686993 570268 293900 6845696 2937585 8027525 5636272 7549936 1778847 6660020 6141407 3607696 9288536 2031193 7190404 7690602 3009621 7358795 7299066 4145970 3022175 8154767 2203771 1739110 2905121 1548903 6709742 ...

output:

26064237505723168 26064681927425462 26065239424690016 26065632351082740 26066020446253495 26066465964009230 26066806090515074 26066835791414896 26066868716329888 26067260057232275 26067330410423907 26067747965925181 26067773891512327 26067785406122649 26067871715381141 26067927748021327 260685780929...

result:

ok single line: '26064237505723168 260646819274...839134791322 26066508758811908 '

Test #44:

score: 1
Accepted
time: 805ms
memory: 389780kb

input:

500000
7462137 7734718 8481229 6992608 6224321 6810411 6222685 3202073 7601813 5585137 7855163 3170177 4716467 1702334 439345 2765492 5541581 8899302 9100093 8896519 5871297 1309023 2992471 6195085 3364657 6815801 9086061 2548006 5901373 3090863 3958041 5923775 5490807 2295888 5190239 2014752 620290...

output:

26106737503844179 26106864371453230 26107028841062674 26107464208203557 26107974457734598 26108318748842448 26108791926090186 26109054438611221 26109283681333829 26109845648560701 26110133461474291 26110539013218577 26110757466427802 26110982472826694 26111054077693384 26111083651642448 261112956190...

result:

ok single line: '26106737503844179 261068643714...901705696299 72416653553115056 '

Test #45:

score: 1
Accepted
time: 484ms
memory: 321964kb

input:

500000
5382500 5882420 9142101 9428971 7159966 9577134 7135742 9746464 6973702 3607223 9999234 2109278 8375172 3942455 2822044 7764943 871833 3751447 6177226 1966185 4168961 792531 4521871 6110769 1705876 5624080 1445819 4506066 4340567 8408933 3459922 2593830 7971808 830995 8706162 3019901 51225 94...

output:

20035625642131 19975441460517 20095800637051 20568904938693 20570306116861 20690610037235 20809697579663 21491722541555 21488088459249 21490971047277 21493033718359 21612569109377 21612032269929 21730364112941 21851481678271 22576774129879 22578057791663 22571826029851 22572082940773 22576110333567 ...

result:

ok single line: '20035625642131 19975441460517 ... 40361177547701 40362008987671 '

Test #46:

score: 1
Accepted
time: 552ms
memory: 270704kb

input:

500000
3948735 7158742 2914228 2805365 8873522 2787764 6670643 8717652 2369019 4490413 5756079 2057891 3535375 3794300 8726249 599092 353757 6550242 3072842 2447313 1384877 1698102 6440316 2439109 4745534 124381 6172269 5424362 2603826 4294928 5670204 9230477 7407866 5879766 2267829 4346225 40812 70...

output:

2745781540703 3868493940301 3617837369026 3621450956994 4746855236144 3868878343609 3869027638615 4745469818814 4740582594524 4742588710926 5992127893334 7241707238181 5996445362300 5995061141253 5996346343164 5992172605064 7241758373542 8491332581250 3995351743193 5118601319599 3995366246681 399535...

result:

ok single line: '2745781540703 3868493940301 36...72 5244933018866 3995365247976 '

Test #47:

score: 1
Accepted
time: 666ms
memory: 297592kb

input:

500000
10000000 8 4 1 3 8 6 4 4 1 4 2 7 1 3 9 2 4 4 3 6 4 3 3 1 2 7 2 7 2 8 9 5 5 6 2 7 4 5 9 2 4 1 2 9 7 6 3 9 7 4 10 5 6 8 5 2 4 10 6 1 2 8 8 4 9 5 6 10 1 8 3 8 8 3 1 1 9 3 7 4 2 9 4 5 4 5 6 8 3 9 3 6 3 1 10 10 1 5 2 7 9 5 6 6 6 2 5 1 10 9 8 7 2 9 7 8 9 5 7 7 4 9 10 4 5 10 1 2 2 8 1 10 4 3 6 7 9 3...

output:

0 7471958 7845268 1779615 8686430 8715765 3079138 8978185 9974177 1572273 9200399 9062452 9626501 11306354 10800930 10394061 10153212 4395408 10780340 11325405 3140013 1597489 11310607 2940884 10389532 9204104 11721900 12042314 12043215 2914167 13349513 11389764 10429611 13365230 11474114 4262259 13...

result:

ok single line: '0 7471958 7845268 1779615 8686...375311 1375306 1375311 1375313 '

Test #48:

score: 1
Accepted
time: 741ms
memory: 436596kb

input:

500000
1 1 7 1 1 8 7 5 4 7 1 1 4 2 3 8 8 2 8 4 5 8 8 4 5 4 5 9 7 7 10 1 3 3 5 8 5 2 10 4 9 3 3 1 10 10 4 8 5 10 6 1 6 10 5 7 8 3 1 10 8 1 6 8 7 6 10 1 3 9 8 9 10 4 1 1 1 10 7 10 3 1 5 4 1 9 4 4 5 4 6 5 7 4 5 1 3 6 1 9 10 8 7 2 9 6 10 10 8 10 9 7 9 6 1 9 1 9 9 4 7 2 10 4 2 4 3 5 6 4 1 10 7 4 9 6 3 7 ...

output:

75683758538 75683779743 75683798875 75683820777 75683841987 75683863195 75683883025 75683903558 75683922714 75683944666 75683965948 75683987932 75684009212 75684030496 75684051070 75684071652 75684088690 75684110708 75684128451 75684149763 75684171801 75684190268 75684208739 75684228656 75684250736 ...

result:

ok single line: '75683758538 75683779743 756837...09429 75834953947 137467529354 '