QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#189850#6117. Determine The Fluctuation BonusKKT89AC ✓65ms10760kbC++173.8kb2023-09-28 00:40:502023-09-28 00:40:51

Judging History

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

  • [2023-09-28 00:40:51]
  • 评测
  • 测评结果:AC
  • 用时:65ms
  • 内存:10760kb
  • [2023-09-28 00:40:50]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline ll time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

// 区間加算+1点取得
// 0-indexed
template<typename T>
struct BIT{
    int n;
    vector<T> bit;
    BIT(int n_=0):n(n_),bit(n+1){}
    T get(int i){
        T res=0;
        i++;
        while(i<bit.size()){
            res+=bit[i];
            i+=(i&-i);
        }
        return res;
    }
    void add(int i,T a){
        i++;
        while(i){
            bit[i]+=a;
            i-=(i&-i);
        }
    }
    // 区間[l,r]にaを足す
    void add(int l,int r,T a){
        add(r,a);
        add(l-1,-a);
    }
};

// 1-indexed
template<typename T>
struct BIT2{
    int n;
    vector<T> bit;
    BIT2(int n_=0):n(n_),bit(n+1){}
    T sum(int i){
        T res=0;
        for(;i>0;i-=(i&-i))res+=bit[i];
        return res;
    }
    void add(int i,T a){
        if(i==0)return;
        for(;i<=n;i+=(i&-i)){bit[i]+=a;}
    }
    int lower_bound(T k){ // k<=sum(res)
        if(k<=0)return 0;
        int res=0,i=1;
        while((i<<1)<=n)i<<=1;
        for(;i;i>>=1){
            if(res+i<=n&&bit[res+i]<k)k-=bit[res+=i];
        }
        return res+1;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    vector<int> a(q),b(q);
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i];
        a[i]--;
    }
    for(int i=0;i<n;i++){
        a.push_back(i);
        b.push_back(0);
        q++;
    }
    vector<ll> point(n);
    vector<ll> p={0};
    vector<ll> res(n);
    {
        vector<ll> po(n);
        for(int i=0;i<q;i++){
            po[a[i]] += b[i];
            p.push_back(po[a[i]]);
        }
        sort(p.begin(), p.end());
        p.erase(unique(p.begin(), p.end()), p.end());
    }
    auto get_point_index=[&](ll po)->int{
        return lower_bound(p.begin(), p.end(), po) - p.begin();
    };

    vector<ll> memo(n);
    int m = p.size();
    BIT<ll> bit(m);
    BIT2<ll> bit2(m);
    int idx = get_point_index(0);
    bit2.add(idx+1, n);
    vector<int> po_idx(n, idx);

    for(int i=0;i<q;i++){
        int cur = po_idx[a[i]];
        // cout << point[0] << " " << point[1] << " " << point[2] << " " << a[i] << "'s pre: ";
        point[a[i]] += b[i];
        int nxt = get_point_index(point[a[i]]);
        int pre_standing = n - bit2.sum(cur+1);
        // cout << pre_standing << endl;
        bit2.add(cur+1, -1);
        bit2.add(nxt+1, 1);
        // cout << point[0] << " " << point[1] << " " << point[2] << " " << a[i] << "'s nxt: ";
        int nxt_standing = n - bit2.sum(nxt+1);
        // cout << nxt_standing << endl;
        res[a[i]] += abs(nxt_standing - pre_standing);
        res[a[i]] += bit.get(cur) - memo[a[i]];
        if(cur < nxt){
            bit.add(cur, nxt-1, 1);
        }
        else if(nxt < cur){
            bit.add(nxt, cur-1, 1);
        }
        memo[a[i]] = bit.get(nxt);
        po_idx[a[i]] = nxt;
    }

    for(int i=0;i<n;i++){
        cout << res[i] << "\n";
    }
}

详细

Test #1:

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

input:

3 7
2 -1
1 4
2 5
3 6
1 -7
3 -6
2 9

output:

2
6
5

result:

ok 3 number(s): "2 6 5"

Test #2:

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

input:

9 5
2 10
2 -20
2 20
2 -20
2 20

output:

5
32
5
5
5
5
5
5
5

result:

ok 9 numbers

Test #3:

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

input:

5 10
1 0
3 0
2 0
5 0
4 0
1 0
3 0
2 0
5 0
4 0

output:

0
0
0
0
0

result:

ok 5 number(s): "0 0 0 0 0"

Test #4:

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

input:

1 1
1 0

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

1 1
1 -1000000000

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

1 1
1 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 36ms
memory: 6764kb

input:

34 99924
5 384094577
32 -796292690
21 -811649302
16 962640530
11 -949299967
26 946724925
32 -871556791
13 -597225272
5 -462265209
17 -360565332
30 973334595
26 65508285
25 -313976558
11 -305308663
4 44272276
3 505903660
19 -828537724
7 -809263187
5 -127755414
19 168244448
13 451711380
17 706137232
2...

output:

1710
2465
2377
1036
2028
1650
2222
2291
2113
579
1536
1820
2479
1610
2210
1395
2213
2289
804
1996
2692
1363
1395
767
1668
1740
1103
1954
1101
2137
1869
1735
2466
2356

result:

ok 34 numbers

Test #8:

score: 0
Accepted
time: 37ms
memory: 6692kb

input:

443 99904
355 776573502
441 -293834208
375 -837011997
40 2774488
397 -249123167
69 -668289981
43 126338528
157 72371393
305 -608040225
253 -492951696
117 -13750067
77 -926024146
115 -887142637
146 585581525
118 -262829358
48 683226063
235 -844096239
69 513944511
223 -498788495
241 -911077572
113 -93...

output:

7435
7270
6432
7641
2790
7721
3771
6005
7048
6948
7038
6544
7023
7418
7049
5335
5809
5634
5960
4388
5976
7737
6746
3312
7530
1984
6800
7404
6116
7491
4906
5022
7280
6565
7198
6032
7810
2660
1697
7036
4367
8059
4639
8228
5447
6877
6983
6887
2793
7200
7466
6033
5821
7692
7465
7800
7458
5839
6406
7130
...

result:

ok 443 numbers

Test #9:

score: 0
Accepted
time: 37ms
memory: 6776kb

input:

240 99983
104 -95278518
231 572854945
93 -368197265
174 -738422454
193 521431685
90 655012878
65 301059792
147 -403962108
21 -858177820
87 223139155
181 -959038878
68 -14423910
30 -699054356
120 435440768
82 983702786
63 211402654
217 92961114
162 -358114816
23 779543403
160 -455406864
201 -48723282...

output:

4457
4667
4950
6031
3883
4270
6068
6035
4719
2709
1574
4796
5219
2339
4844
5880
2683
5995
2596
5281
5413
5607
4429
5419
5911
5350
5792
5301
4988
3019
5353
756
5064
4800
3912
4133
4306
2924
5941
5976
4870
4644
4357
4481
3119
4770
5603
5480
5434
4580
2580
5168
4687
5494
4377
4224
4821
6389
5734
6284
5...

result:

ok 240 numbers

Test #10:

score: 0
Accepted
time: 65ms
memory: 10616kb

input:

100000 100000
17709 872080604
29908 948861030
31960 -909331019
4551 573019995
74654 -688106402
17784 -165486948
24765 -503004971
93138 -47580542
98455 -708200927
35979 -874695335
86738 -326977214
48335 912206161
13410 -654819759
52214 -917196936
97024 -728452010
40411 3245912
10276 885241981
59066 6...

output:

61740
40683
105833
105202
37101
111175
40683
260900
40683
106677
98202
29090
40683
100241
40683
111627
40683
179768
40683
40683
81997
40683
36117
106245
40683
236625
41443
40683
106611
121683
40683
57299
40683
93545
40683
44340
118578
40683
40683
27289
103670
40683
40683
40683
40683
42925
40683
4068...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 60ms
memory: 10600kb

input:

100000 100000
6073 685908938
16764 704624104
95954 273780301
19560 -659974636
69166 -6946088
17735 -461272926
72900 567789228
2748 -310095707
34051 643569128
49582 -223620070
28175 -390945828
55829 -361864174
41031 532714060
82113 403993012
25401 -160547950
11547 804155155
41120 -116232798
4795 7510...

output:

43092
40446
40446
47931
127194
40446
45880
9151
41302
37379
104574
124235
21603
105718
40446
40446
40446
92055
64633
97507
130625
48950
98322
44598
97514
40446
40446
40446
40446
104654
103020
40446
30511
176745
40446
62017
12307
40446
40446
40446
40446
40446
40446
62977
40446
40446
54007
40446
49588...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 61ms
memory: 10688kb

input:

100000 100000
97454 -628479669
43620 -691823768
98133 -126622464
63692 -911353704
87969 830546574
74799 361384781
95616 434222246
44630 -693601283
57761 477744960
36486 -787190361
11808 -356573877
44931 407975831
84420 890951
62598 -82219099
58361 590326125
45300 -169604191
30262 590830618
61953 585...

output:

104465
100975
106920
102530
40354
40354
40354
49984
97678
156033
101676
40354
107006
104424
40354
38437
60900
56269
40354
185806
40354
42315
106638
40354
41505
13350
25398
89905
202526
96626
40894
40354
86958
40354
203569
120096
25247
40354
40354
50785
109313
40354
46556
45287
40354
40354
35229
4372...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 61ms
memory: 10612kb

input:

100000 100000
27477 676816623
61731 -99391452
43666 -981400905
82438 -970831219
54455 -950333903
11160 -728862086
68822 807890073
96505 -601154870
12638 790703265
14467 733765940
90712 96636590
44077 -343657008
97736 154593712
73661 -637118422
67953 68826315
79183 418700723
56485 -331752044
50151 72...

output:

40256
61684
82805
30589
108123
101175
40256
59474
40256
40256
40256
92649
40256
40256
40256
40256
187241
40256
40256
38905
51604
84720
40256
40797
27791
45350
114858
112966
42575
40256
40256
104709
37989
165064
40256
40256
33638
60662
104493
195153
33179
103289
111411
40256
40256
116470
40256
40256
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 60ms
memory: 10696kb

input:

100000 100000
75703 541330936
88274 91946190
56588 32766958
95138 -7915439
92675 -709848272
65937 -545936022
53469 305332762
43622 888353693
73592 -480465072
24390 -797198315
6128 -898212765
80750 -916911239
97152 -244544744
60372 -213797099
48804 720335891
28019 585130247
99635 884179031
65813 5030...

output:

98435
29089
40285
40285
137599
103400
108928
40285
40285
40285
95701
103489
134377
44546
57762
45583
47168
40285
36727
116850
41416
67042
40704
201454
40285
110336
40285
145550
40608
110575
40285
40285
99415
101023
46222
115518
27881
40285
96437
48332
40285
132932
40285
102571
40285
43560
40285
4028...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 59ms
memory: 10648kb

input:

99925 99931
44574 -930114987
63860 -829383710
42760 -738038607
77622 -555546593
73095 -452821535
19483 -924945
73679 859098486
40562 970516634
6918 299131558
4508 683291169
37516 -597986810
95574 -806768619
924 -963661000
47618 665067787
8412 -562845077
34188 -164693371
58674 -693627556
66604 -10101...

output:

138637
104464
40212
40212
71097
40212
40212
104374
40212
40212
40212
40212
188581
183556
46722
40212
96082
108578
130967
40212
40212
100812
52746
36674
40686
40212
32754
40689
40212
40212
40212
98649
105673
40212
32180
197252
104774
124535
40212
95448
129138
40212
40212
38507
26604
108618
111446
101...

result:

ok 99925 numbers

Test #16:

score: 0
Accepted
time: 64ms
memory: 10608kb

input:

99987 99985
4703 -355089109
58679 -152394746
10698 -361633363
49456 322829368
50239 621663148
15160 609948723
94251 -158786940
1539 743498121
48312 -52943535
36148 631258824
24656 -993048379
92130 405573677
53346 -422420456
44890 511431855
60792 607203514
50652 -179513074
41238 205314888
16215 94992...

output:

40252
38925
40252
45751
107325
103265
40163
112195
125108
113175
40252
40252
38020
42437
40252
114142
111856
175904
119800
25799
40252
132111
122850
128502
116250
40252
130968
93179
40252
43273
43475
100758
40252
52469
81633
40252
111563
90736
107798
96098
40252
40554
110711
46273
101846
166156
1062...

result:

ok 99987 numbers

Test #17:

score: 0
Accepted
time: 60ms
memory: 10620kb

input:

99901 99967
92790 982800752
54919 -781431144
82593 466237047
86824 -612261029
58433 110782408
40688 438081589
20313 -142105395
38736 -514306527
31712 471261698
89783 -254718671
8382 -196339579
30095 -607222390
11253 563987079
72082 471370938
40784 -336902798
59106 399916553
58011 -596419087
98651 -2...

output:

40295
41570
116372
40295
40295
40295
184987
111845
111832
40295
40322
46142
101187
13367
72696
40295
40295
40295
40295
40295
40295
95984
91471
40295
17660
40295
113122
40790
51669
342301
40295
40295
40295
40447
40295
162303
40295
40295
120154
104964
40295
40295
109461
40295
137657
40295
40295
124430...

result:

ok 99901 numbers

Test #18:

score: 0
Accepted
time: 59ms
memory: 10608kb

input:

99932 99996
608 244042746
21216 883631782
22862 -620435779
12855 -389304483
58548 771520302
65920 -386272201
91317 -414034375
76503 938785012
36904 -661729890
83821 -152242789
13419 -267875950
70078 23582279
47540 -774659311
8459 -95171186
7436 -478408249
54109 263754428
89567 -187906056
25163 -6625...

output:

40571
40571
26488
40571
48405
177205
40571
86584
14511
40571
101052
113338
40571
66242
115084
192000
40571
110166
40571
126825
118959
40571
38685
40571
40571
40571
107219
40571
40571
43952
40571
32334
40571
40571
76645
105215
40571
40571
40571
106163
40571
40571
103216
40571
40571
40571
40571
50087
...

result:

ok 99932 numbers

Test #19:

score: 0
Accepted
time: 60ms
memory: 10556kb

input:

99963 99952
89647 -334330647
22261 -308934033
73792 -257689647
25963 -25760631
79860 -498024724
47121 284497236
81994 147940214
14196 -973002151
47084 197383442
12293 160152420
54938 -2551518
61349 -659687761
93458 -805176127
25880 -434678276
22261 -404568050
6382 -847812519
74448 -774446751
71958 -...

output:

106559
14428
40860
40510
27579
40510
217208
85772
40510
98814
113377
49610
109411
20994
40510
40510
40510
40510
40510
113215
42278
40510
40510
40510
83537
41422
188048
40510
41730
93128
109145
62759
38048
180517
40517
40510
40510
17015
31746
105643
40510
40510
105690
40510
40510
168442
144379
40510
...

result:

ok 99963 numbers

Test #20:

score: 0
Accepted
time: 32ms
memory: 10760kb

input:

100000 100000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 1000000000
6198 100000000...

output:

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
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
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 39ms
memory: 10640kb

input:

100000 100000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -1000000000
48737 -100000000...

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 100000 numbers

Test #22:

score: 0
Accepted
time: 19ms
memory: 9720kb

input:

100000 100000
44667 0
25080 0
95139 0
93749 0
91668 0
38984 0
72350 0
90773 0
97194 0
49564 0
46824 0
2076 0
91275 0
33026 0
94880 0
74006 0
72291 0
95417 0
22139 0
50562 0
93354 0
48895 0
12068 0
51579 0
71018 0
34626 0
10037 0
34301 0
93504 0
21704 0
93612 0
98967 0
7165 0
30989 0
20703 0
91185 0
...

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 100000 numbers

Test #23:

score: 0
Accepted
time: 27ms
memory: 9740kb

input:

100000 100000
31630 1000000000
91729 1000000000
66785 1000000000
34153 1000000000
95253 1000000000
23979 1000000000
19035 1000000000
63482 1000000000
48341 1000000000
48737 1000000000
19944 1000000000
54289 1000000000
37720 1000000000
20424 1000000000
95521 1000000000
52089 1000000000
18875 10000000...

output:

63276
63276
93341
55289
109800
24998
94387
63276
81400
97203
29463
63276
63276
93641
92607
99975
109018
63276
63276
53065
66640
63276
63276
63276
46175
46103
110982
96681
63276
65290
99306
31686
47631
63276
63276
63276
63276
20551
89821
32805
56820
63276
63276
49809
91521
63276
97291
41653
63276
422...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 22ms
memory: 9696kb

input:

100000 100000
90573 -1000000000
34786 -1000000000
22723 -1000000000
39878 -1000000000
43302 -1000000000
47329 -1000000000
57342 -1000000000
63240 -1000000000
76849 -1000000000
17722 -1000000000
82847 -1000000000
30247 -1000000000
49219 -1000000000
25348 -1000000000
17296 -1000000000
87356 -100000000...

output:

134427
57851
49297
141263
80689
132395
0
128775
0
0
0
160397
86349
49017
67809
69189
0
157089
0
0
124135
175629
152673
110593
197351
0
0
110941
151601
56629
146093
0
0
139883
113511
153313
82167
80643
55955
0
0
37941
158400
108741
111479
62059
96087
111971
116611
110881
43393
0
169595
0
81127
73035
...

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 63ms
memory: 10612kb

input:

100000 100000
7288 859347570
40311 408878434
33759 773171784
5363 865151431
76647 362667813
27703 302483682
57212 698502810
54315 454144553
97745 987144232
48522 189019586
35298 183825453
7672 977522502
15177 249551426
98644 638319515
5654 212774722
58514 107146604
73149 108680766
86272 61190982
342...

output:

83393
63128
81143
91276
42740
63128
61892
72438
102940
63128
63128
63128
63128
92163
87593
87042
63341
65098
63128
82531
77726
64454
43181
88280
76190
88169
63128
63128
64625
63128
63128
63128
63128
66978
55783
61495
63128
67741
63128
63128
68581
63128
63128
46660
63128
55635
63128
74834
32556
63128...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 54ms
memory: 10644kb

input:

100000 100000
87535 -102690929
4033 -123677765
35349 -342963497
58360 -464005372
32394 -104779639
66946 -771385058
41519 -18617130
40252 -93982086
89079 -787443637
77316 -244366955
31780 -505867803
89252 -974554355
38479 -266494231
3325 -108872072
26646 -349684469
89207 -483855335
77493 -79646788
43...

output:

107078
139285
0
114221
83831
127293
125767
0
0
0
126699
0
0
141632
118288
136486
125162
0
73475
118548
106871
0
0
98923
0
0
0
0
142660
108999
109775
112060
98794
0
160845
0
0
0
138533
113929
0
0
0
0
0
0
162039
118117
140093
113868
0
85885
109596
0
108096
0
0
0
72069
78320
120010
147314
84192
137707
...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 21ms
memory: 9552kb

input:

100000 100000
43101 1000000000
48875 1000000000
58424 1000000000
89469 -1000000000
52420 1000000000
25969 -1000000000
44443 -1000000000
13676 1000000000
47934 1000000000
23437 -1000000000
28619 1000000000
28287 -1000000000
67162 1000000000
83707 1000000000
41931 1000000000
94943 -1000000000
91072 10...

output:

40627
40627
40627
46709
55225
116458
30215
136514
40627
40627
40627
190122
40627
40627
35149
104274
28919
40627
123154
40627
101812
60157
40627
52520
120092
131698
13491
107568
98130
25585
40627
121758
48977
40627
121304
214555
40627
108632
137458
9238
52871
35004
23625
40627
44535
40627
40627
31433...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 36ms
memory: 10620kb

input:

100000 100000
68332 -1
68332 2
68332 -3
68332 4
68332 -5
68332 6
68332 -7
68332 8
68332 -9
68332 10
68332 -11
68332 12
68332 -13
68332 14
68332 -15
68332 16
68332 -17
68332 18
68332 -19
68332 20
68332 -21
68332 22
68332 -23
68332 24
68332 -25
68332 26
68332 -27
68332 28
68332 -29
68332 30
68332 -31
...

output:

99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
...

result:

ok 100000 numbers