QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#221190#7611. Max-Minucup-team180#AC ✓775ms41144kbC++176.2kb2023-10-21 10:45:372023-10-21 10:45:37

Judging History

你现在查看的是最新测评结果

  • [2023-10-21 10:45:37]
  • 评测
  • 测评结果:AC
  • 用时:775ms
  • 内存:41144kb
  • [2023-10-21 10:45:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
#ifndef ATCODER_SEGTREE_HPP
#define ATCODER_SEGTREE_HPP 1

#include <algorithm>
#include <cassert>
#include <functional>
#include <vector>

#ifndef ATCODER_INTERNAL_BITOP_HPP
#define ATCODER_INTERNAL_BITOP_HPP 1

#ifdef _MSC_VER
#include <intrin.h>
#endif

#if __cplusplus >= 202002L
#include <bit>
#endif

namespace atcoder {

namespace internal {

#if __cplusplus >= 202002L

using std::bit_ceil;

#else

// @return same with std::bit::bit_ceil
unsigned int bit_ceil(unsigned int n) {
    unsigned int x = 1;
    while (x < (unsigned int)(n)) x *= 2;
    return x;
}

#endif

// @param n `1 <= n`
// @return same with std::bit::countr_zero
int countr_zero(unsigned int n) {
#ifdef _MSC_VER
    unsigned long index;
    _BitScanForward(&index, n);
    return index;
#else
    return __builtin_ctz(n);
#endif
}

// @param n `1 <= n`
// @return same with std::bit::countr_zero
constexpr int countr_zero_constexpr(unsigned int n) {
    int x = 0;
    while (!(n & (1 << x))) x++;
    return x;
}

}  // namespace internal

}  // namespace atcoder

#endif  // ATCODER_INTERNAL_BITOP_HPP

namespace atcoder {

#if __cplusplus >= 201703L

template <class S, auto op, auto e> struct segtree {
    static_assert(std::is_convertible_v<decltype(op), std::function<S(S, S)>>,
                  "op must work as S(S, S)");
    static_assert(std::is_convertible_v<decltype(e), std::function<S()>>,
                  "e must work as S()");

#else

template <class S, S (*op)(S, S), S (*e)()> struct segtree {

#endif

  public:
    segtree() : segtree(0) {}
    explicit segtree(int n) : segtree(std::vector<S>(n, e())) {}
    explicit segtree(const std::vector<S>& v) : _n(int(v.size())) {
        size = (int)internal::bit_ceil((unsigned int)(_n));
        log = internal::countr_zero((unsigned int)size);
        d = std::vector<S>(2 * size, e());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) {
            update(i);
        }
    }

    void set(int p, S x) {
        assert(0 <= p && p < _n);
        p += size;
        d[p] = x;
        for (int i = 1; i <= log; i++) update(p >> i);
    }

    S get(int p) const {
        assert(0 <= p && p < _n);
        return d[p + size];
    }

    S prod(int l, int r) const {
        assert(0 <= l && l <= r && r <= _n);
        S sml = e(), smr = e();
        l += size;
        r += size;

        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }
        return op(sml, smr);
    }

    S all_prod() const { return d[1]; }

    template <bool (*f)(S)> int max_right(int l) const {
        return max_right(l, [](S x) { return f(x); });
    }
    template <class F> int max_right(int l, F f) const {
        assert(0 <= l && l <= _n);
        assert(f(e()));
        if (l == _n) return _n;
        l += size;
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!f(op(sm, d[l]))) {
                while (l < size) {
                    l = (2 * l);
                    if (f(op(sm, d[l]))) {
                        sm = op(sm, d[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, d[l]);
            l++;
        } while ((l & -l) != l);
        return _n;
    }

    template <bool (*f)(S)> int min_left(int r) const {
        return min_left(r, [](S x) { return f(x); });
    }
    template <class F> int min_left(int r, F f) const {
        assert(0 <= r && r <= _n);
        assert(f(e()));
        if (r == 0) return 0;
        r += size;
        S sm = e();
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!f(op(d[r], sm))) {
                while (r < size) {
                    r = (2 * r + 1);
                    if (f(op(d[r], sm))) {
                        sm = op(d[r], sm);
                        r--;
                    }
                }
                return r + 1 - size;
            }
            sm = op(d[r], sm);
        } while ((r & -r) != r);
        return 0;
    }

  private:
    int _n, size, log;
    std::vector<S> d;

    void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
};

}  // namespace atcoder

#endif  // ATCODER_SEGTREE_HPP

int op(int a, int b){
  return max(a, b);
}
int e(){
  return -INF;
}
int VALUE;
bool f(int x){
  return x < VALUE;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<char> c(q);
  vector<int> p(q);
  for (int i = 0; i < q; i++){
    cin >> c[i] >> p[i];
    p[i]--;
  }
  vector<long long> ans(q, 0);
  for (int i = 0; i < 2; i++){
    vector<int> idx(n);
    for (int j = 0; j < n; j++){
      idx[j] = j;
    }
    sort(idx.begin(), idx.end(), [&](int j, int k){
      return a[j] > a[k];
    });
    set<int> st = {-1, n};
    long long sum = 0;
    for (int j = 0; j < n; j++){
      int L = *prev(st.lower_bound(idx[j])) + 1;
      int R = *st.lower_bound(idx[j]);
      sum += (long long) a[idx[j]] * (idx[j] - L + 1) * (R - idx[j]);
      st.insert(idx[j]);
    }
    atcoder::segtree<int, op, e> ST(a);
    for (int j = 0; j < q; j++){
      if (c[j] == '+'){
        ST.set(p[j], ST.get(p[j]) + 1);
        VALUE = ST.get(p[j]);
        int L = ST.min_left<f>(p[j]);
        int R = ST.max_right<f>(p[j] + 1);
        sum += (long long) (p[j] - L + 1) * (R - p[j]);
      }
      if (c[j] == '-'){
        VALUE = ST.get(p[j]);
        int L = ST.min_left<f>(p[j]);
        int R = ST.max_right<f>(p[j] + 1);
        sum -= (long long) (p[j] - L + 1) * (R - p[j]);
        ST.set(p[j], VALUE - 1);
      }
      ans[j] += sum;
    }
    for (int j = 0; j < n; j++){
      a[j] *= -1;
    }
    for (int j = 0; j < q; j++){
      c[j] ^= '+' ^ '-';
    }
  }
  for (int i = 0; i < q; i++){
    cout << ans[i] << '\n';
  }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

3 6
0 0 -1
+ 3
+ 3
- 2
- 2
+ 2
+ 1

output:

0
2
5
8
5
6

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

1 1
0
+ 1

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 105ms
memory: 9728kb

input:

1025 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -10...

output:

104959999997
104960179065
104960179062
104960199263
104960199266
104960293315
104960472383
104960378334
104960526073
104960517442
104960526681
104960705749
104960798348
104960619280
104960619277
104960619274
104960619271
104960619274
104960440206
104960652725
104960652722
104960652725
104960652722
1...

result:

ok 500000 lines

Test #4:

score: 0
Accepted
time: 775ms
memory: 40964kb

input:

500000 500000
54181 46637 -2621 18334 55372 -53002 82186 -1463 93261 63053 -79663 98576 -95766 91470 58638 31500 85909 76726 -20694 -5761 48617 34968 4886 55627 -42510 45591 89565 -79895 65387 -64403 -77506 97343 94193 46041 -85383 2673 74798 -54541 43604 -29672 72296 -28317 8037 -65719 -54207 53468...

output:

24998004876352508
24998004876352519
24998004876352517
24998004876356492
24998004876355181
24998004876355182
24998004876355205
24998004876355205
24998004876355210
24998004876355157
24998004876355142
24998004876355146
24998004876353597
24998004876353606
24998004876354550
24998004876354548
249980048763...

result:

ok 500000 lines

Test #5:

score: 0
Accepted
time: 515ms
memory: 40988kb

input:

500000 500000
-1 -2 1 1 0 -3 0 3 1 0 -2 -1 1 -2 1 3 0 -3 -3 -2 -1 -3 1 -2 -3 0 2 0 -1 0 -2 -1 2 0 -3 2 -1 -3 -2 2 -2 -1 -1 -1 1 -3 0 0 -3 3 -3 0 0 -3 1 0 3 -2 1 1 0 2 1 1 -2 2 -2 -3 1 1 0 -2 -3 -3 0 1 -1 -1 1 1 1 -3 2 -2 3 1 2 3 3 0 -1 -1 -2 1 2 1 -2 -2 3 1 3 2 -1 2 -3 -1 -2 -2 2 -2 3 -1 3 3 3 -3 1 ...

output:

749990346961
749990346971
749990346988
749990346992
749990346993
749990346993
809605564336
871925650829
881066164939
881066164942
881066164934
881066164934
881066164969
881066164972
881066164973
887216105984
887216105969
887216105974
900693012690
902436118847
902436118827
902436118818
902436118929
9...

result:

ok 500000 lines

Test #6:

score: 0
Accepted
time: 532ms
memory: 41124kb

input:

500000 500000
50000 50000 49999 49998 49998 49997 49997 49997 49996 49995 49995 49995 49992 49992 49991 49990 49990 49990 49989 49989 49989 49988 49987 49987 49986 49986 49986 49986 49985 49985 49985 49984 49984 49984 49984 49983 49983 49983 49982 49982 49982 49981 49980 49979 49979 49979 49979 4997...

output:

6251153789925450
6251153789763576
6251153789541527
6251153790454170
6251153790900554
6251153790827024
6251153790727306
6251153791965831
6251153793320525
6251153794182062
6251153794344648
6251153795092139
6251153794954252
6251153795716866
6251153795803477
6251153796125622
6251153796351459
62511537964...

result:

ok 500000 lines

Test #7:

score: 0
Accepted
time: 537ms
memory: 41024kb

input:

500000 500000
50001 50000 49998 49999 49997 49998 49997 49997 49995 49995 49996 49996 49996 49995 49995 49994 49993 49994 49994 49994 49993 49993 49991 49993 49989 49990 49989 49988 49987 49988 49986 49985 49985 49987 49985 49985 49981 49982 49982 49982 49983 49981 49980 49980 49980 49980 49979 4997...

output:

6253323343133900
6253323343563847
6253323343418702
6253323342998034
6253323342998030
6253323342998051
6253323342998048
6253323342998049
6253323342885308
6253323341644059
6253323341418715
6253323341658184
6253323344075703
6253323342343989
6253323342369475
6253323341943180
6253323341780542
62533233416...

result:

ok 500000 lines

Test #8:

score: 0
Accepted
time: 519ms
memory: 41000kb

input:

500000 500000
-5700 -5699 -5700 -5700 -5698 -5699 -5698 -5699 -5700 -5699 -5701 -5700 -5700 -5697 -5699 -5699 -5700 -5699 -5699 -5700 -5698 -5700 -5700 -5700 -5700 -5695 -5699 -5700 -5697 -5699 -5700 -5697 -5699 -5700 -5700 -5699 -5699 -5699 -5699 -5698 -5698 -5698 -5701 -5699 -5699 -5698 -5695 -569...

output:

713179809156264
713179809156215
713179809156210
713179809156208
713179809156193
713179809156196
713179809156143
713179809156146
713179809108795
713179809065887
713179807453886
713179807453863
713179807453865
713179807453862
713179807453941
713179807453941
713179807453928
713179807453923
713179807453...

result:

ok 500000 lines

Test #9:

score: 0
Accepted
time: 510ms
memory: 41068kb

input:

500000 500000
5 3 -1 3 -2 -2 4 3 -5 3 5 -4 0 5 2 3 3 -4 4 -4 3 -3 2 -3 -4 -3 3 -1 -4 1 -4 -5 4 -3 2 1 5 -3 4 0 3 -5 2 2 3 -3 0 0 5 0 4 -4 5 3 -3 4 0 -4 -3 3 3 0 -3 1 -3 3 -5 4 5 -3 4 4 -4 1 1 5 1 -3 5 5 -3 2 -2 1 -5 -2 5 5 1 -3 2 -5 -4 -2 0 5 -3 2 -2 -1 -1 -3 1 5 -1 5 3 5 -1 -1 -3 2 4 -1 1 -3 -3 -3 ...

output:

1249980351918
1249980351663
1249980351615
1249980351588
1249980351589
1249980351478
1310085722571
1310085722532
1310085722515
1310085722507
1310085722546
1310085722547
1310085722658
1310085722571
1370191974458
1370191974447
1370191974420
1370195262616
1370195261697
1370195261432
1310089009545
131008...

result:

ok 500000 lines

Test #10:

score: 0
Accepted
time: 724ms
memory: 40976kb

input:

500000 500000
-9 197 -106 -353 178 722 180 341 729 -714 781 -314 -92 -706 479 -686 -744 626 182 -851 -121 -927 349 -532 346 509 288 -991 788 516 773 532 -576 178 857 -501 404 537 858 676 -410 887 23 -764 -729 -371 -886 -599 127 134 -259 59 77 -293 -46 -733 605 279 -829 -59 -147 180 -504 -484 113 -82...

output:

250046403667257
250046403454956
250046400838453
250046388481310
250079118507169
250099029784939
250104429790746
250108486422971
250111235091744
250111234969434
250171086933451
250171086163036
250171080534967
250167023902742
250167024025052
250211137697815
250220875267276
250280727231293
250220875267...

result:

ok 500000 lines

Test #11:

score: 0
Accepted
time: 739ms
memory: 41052kb

input:

500000 500000
-84462 -88141 66082 -42728 -51534 8492 87024 -51053 -46657 -65482 -84566 25015 75859 17241 -80367 -96705 -48968 -39472 26382 -63638 89126 6784 20239 91981 -50116 -64446 8316 -91840 62002 -76657 6396 20060 65350 85101 -69463 16461 71644 47340 33461 -77765 -45992 -99011 10371 72086 42468...

output:

24997574286813795
24997593578536523
24997583886102441
24997593728194163
24997551354790195
24997519958850867
24997530857361907
24997560658303836
24997592054243164
24997597280670083
24997567479728154
24997563357846415
24997562743054666
24997597589811321
24997596678167068
24997591451740149
249975923633...

result:

ok 500000 lines

Test #12:

score: 0
Accepted
time: 454ms
memory: 41076kb

input:

500000 500000
23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 2331...

output:

4633301419
9266602838
9481917507
9697232176
5063930757
9697232176
5063930757
430629338
57666499462
68814346015
77988562807
82621864226
82406549557
82674184398
82691573217
90036097739
90018708920
120785400551
126906373306
120785400551
160309186805
169411244860
174309191283
182132073382
185590046403
1...

result:

ok 500000 lines

Test #13:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

100 100
10 -1 7 10 6 0 -6 1 -2 -10 -3 8 8 6 5 10 5 8 -8 7 -6 6 10 9 -5 -5 -1 -9 -7 0 -6 2 2 6 -6 2 -9 7 1 4 10 1 -1 -7 -7 4 -7 -5 -4 -5 -7 -6 -1 8 -4 10 -2 -7 9 -5 4 6 9 2 8 5 -4 7 2 6 4 -4 -6 7 -1 1 -4 10 -4 4 -1 2 -3 7 -2 -5 4 8 -9 -3 -7 3 3 -8 -4 -6 3 -6 9 -9
+ 11
+ 63
+ 100
+ 1
- 69
+ 95
+ 94
+ ...

output:

87561
87665
87655
87754
87759
87762
87733
87726
87691
87691
87680
87675
89445
89336
90815
90812
90818
90819
90820
90817
90806
90807
90818
90821
90832
90835
90815
90810
90807
90817
90846
90839
90804
90807
90804
90819
90834
90914
90876
90872
90883
91257
91257
91262
91999
92012
92013
92013
92008
92015
...

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 424ms
memory: 41076kb

input:

500000 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -...

output:

24999949999999997
24999949999999994
24999949999999991
24999993576533458
24999993576533455
24999993576533458
25000056071183135
25000056071183132
25000058304210031
25000058304210028
25000092108652451
25000092108652448
25000101484742747
25000101484742750
25000101484742753
25000085782690830
250000764066...

result:

ok 500000 lines

Test #15:

score: 0
Accepted
time: 457ms
memory: 41144kb

input:

500000 500000
80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 8000...

output:

42339799843
45383875254
49284061703
60873242339
62630303518
64299196641
68199383090
77787173239
101927884956
100258991833
160104055520
156203869071
160104055520
156203869071
96358805384
94601744205
103369110140
117459019587
118288036090
110636443667
109651005618
115305675131
118284987943
10257786585...

result:

ok 500000 lines

Test #16:

score: 0
Accepted
time: 431ms
memory: 40996kb

input:

500000 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -...

output:

24999949999999997
24999949999999994
24999949999999991
24999949999999988
24999949999999985
24999949999999982
24999949999999979
24999949999999976
24999999949192983
24999999949192986
24999999949192989
24999999949192986
24999999949192989
25000002235015500
25000002235015497
25000002235015500
250000013481...

result:

ok 500000 lines

Test #17:

score: 0
Accepted
time: 322ms
memory: 40976kb

input:

500000 500000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000...

output:

499999
999998
1499997
1999996
2499995
2999994
3499993
3999992
4499991
4999990
5499989
5999988
6499987
6999986
7499985
7999984
8499983
8999982
9499981
9999980
10499979
10999978
11499977
11999976
12499975
12999974
13499973
13999972
14499971
14999970
15499969
15999968
16499967
16999966
17499965
1799996...

result:

ok 500000 lines

Test #18:

score: 0
Accepted
time: 327ms
memory: 41072kb

input:

500000 500000
-100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -10000...

output:

499999
999998
1499997
1999996
2499995
2999994
3499993
3999992
4499991
4999990
5499989
5999988
6499987
6999986
7499985
7999984
8499983
8999982
9499981
9999980
10499979
10999978
11499977
11999976
12499975
12999974
13499973
13999972
14499971
14999970
15499969
15999968
16499967
16999966
17499965
1799996...

result:

ok 500000 lines

Test #19:

score: 0
Accepted
time: 375ms
memory: 41016kb

input:

500000 500000
100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 1...

output:

25000012500249999
25000075000499998
25000137500749997
25000200000999996
25000262501249995
25000325001499994
25000387501749993
25000450001999992
25000512502249991
25000575002499990
25000637502749989
25000700002999988
25000762503249987
25000825003499986
25000887503749985
25000950003999984
250010125042...

result:

ok 500000 lines

Test #20:

score: 0
Accepted
time: 357ms
memory: 41068kb

input:

500000 500000
90318 -75898 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 ...

output:

292580101461
292580101458
292580101461
292580101458
292580101461
292580101458
292580101461
292580101462
292580101461
292580101462
292580101461
292580101458
292580101461
292580101458
292580101453
292580101446
292580101453
292580101446
292580101453
292580101458
292580101461
292580101458
292580101453
2...

result:

ok 500000 lines

Test #21:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

100 100
-12 -10 -8 -9 -9 -9 -10 -7 -7 -7 -7 -6 -6 -6 -7 -7 -3 -4 -6 -4 -2 -1 -1 -1 0 0 1 -2 0 2 4 2 5 6 5 6 7 7 7 7 7 7 8 9 9 9 12 8 10 12 9 9 10 8 9 7 7 7 7 7 6 7 4 6 5 4 5 4 4 2 3 1 2 -1 -3 0 -2 0 0 -4 -2 -3 -4 -3 -5 -5 -6 -6 -6 -6 -7 -7 -8 -7 -9 -8 -9 -10 -9 -10
+ 32
- 46
- 72
+ 89
- 99
+ 15
- 30...

output:

62027
62032
62117
62152
62149
62147
62159
62154
62154
61700
61615
61582
61591
61580
61536
61664
61485
61333
61464
61449
61697
61688
61608
59071
59133
59121
58993
58999
58900
58808
59080
59089
59079
59142
59083
59083
59008
59099
59008
58680
58721
58694
58674
58471
58296
58293
58300
58340
58334
58147
...

result:

ok 100 lines

Test #22:

score: 0
Accepted
time: 3ms
memory: 3724kb

input:

300 10000
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37...

output:

10439
0
20487
38976
18489
24788
26515
48108
55219
55458
55039
53960
61735
54624
55631
63846
64457
63612
55397
58477
57866
60681
68896
62656
62811
63585
63430
69589
64910
65065
65224
64822
67084
71503
71248
64825
85668
74399
82070
95789
82070
94759
104976
92287
85127
86911
76694
61899
51955
54519
628...

result:

ok 10000 lines

Test #23:

score: 0
Accepted
time: 3ms
memory: 4020kb

input:

300 10000
-100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -1...

output:

8987099
8990634
8993261
9014576
9014573
9037202
9047341
9047338
9069975
9047338
9047335
9069964
9069967
9069964
9092593
9115222
9115219
9092590
9069961
9069958
9047329
9047332
9046019
9046022
9046019
9046022
9046019
9046022
9046025
9046022
9049165
9046956
9041029
9041026
9063655
9041026
9043705
9043...

result:

ok 10000 lines

Test #24:

score: 0
Accepted
time: 42ms
memory: 9616kb

input:

1 500000
56341
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
- 1
- 1
+ 1
- 1
+ 1
- 1
- 1
- 1
+ 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
+ 1
- 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
+ 1
- 1
- 1
-...

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 500000 lines

Test #25:

score: 0
Accepted
time: 630ms
memory: 34800kb

input:

500000 1
87264 -46622 83983 29780 -26107 34378 47137 -46083 49909 -24411 -48502 52566 -98788 -96543 -38478 29848 62915 4353 37968 13624 10437 -24703 -97034 -30965 -31685 -85360 31834 -34540 68700 45597 -84104 -46937 82101 -64326 58652 93388 29079 28646 -5930 4070 20172 -64537 77467 41029 26395 7374 ...

output:

24998054791576670

result:

ok single line: '24998054791576670'

Test #26:

score: 0
Accepted
time: 111ms
memory: 9584kb

input:

1023 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -10...

output:

104550599997
104550599994
104550599997
104550599994
104550599991
104550599994
104550599991
104550599994
104550845496
104550599994
104550603056
104550603059
104550603062
104550861841
104551121190
104551119553
104550860774
104550914923
104550810614
104551054801
104551054798
104551054795
104551054792
1...

result:

ok 500000 lines

Test #27:

score: 0
Accepted
time: 103ms
memory: 9596kb

input:

1024 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -10...

output:

104755379423
104755200000
104755199997
104755199994
104755199997
104755199994
104755458867
104755458870
104755199997
104755379420
104755199997
104755335560
104755598173
104755603760
104755603763
104755603760
104755468197
104755462610
104755523809
104755542968
104755542965
104755542962
104755573261
1...

result:

ok 500000 lines

Extra Test:

score: 0
Extra Test Passed