QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372257#1280. Fibonacci PartitionRong7AC ✓1372ms50508kbC++1411.1kb2024-03-31 07:58:142024-03-31 07:58:15

Judging History

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

  • [2024-03-31 07:58:15]
  • 评测
  • 测评结果:AC
  • 用时:1372ms
  • 内存:50508kb
  • [2024-03-31 07:58:14]
  • 提交

answer

// Not afraid to dark.

#include <bits/stdc++.h>
using namespace std;

clock_t start_time, end_time;
#define GET_START start_time = clock ();
#define GET_END end_time = clock (); fprintf (stderr, "TIME COSSEMED : %0.3lf\n", 1.0 * (end_time - start_time) / CLOCKS_PER_SEC);

#define int long long

namespace io {
    int read_pos, read_dt; char read_char;
    __inline__ __attribute__ ((always_inline)) int read (int &p = read_pos){
        p = 0, read_dt = 1; read_char = getchar ();
        while (! isdigit (read_char)){
            if (read_char == '-')
                read_dt = - 1;
            read_char = getchar ();
        }
        while (isdigit (read_char)){
            p = (p << 1) + (p << 3) + read_char - 48;
            read_char = getchar ();
        }
        return p = p * read_dt;
    }
    int write_sta[65], write_top;
    __inline__ __attribute__ ((always_inline)) void write (int x){
        if (x < 0)
            putchar ('-'), x = - x;
        write_top = 0;
        do
            write_sta[write_top ++] = x % 10, x /= 10;
        while (x);
        while (write_top)
            putchar (write_sta[-- write_top] + 48);
    }
    int llen;
    __inline__ __attribute__ ((always_inline)) int get_string (char c[], int &len = llen){
        len = 0;
        read_char = getchar ();
        while (read_char == ' ' || read_char == '\n' || read_char == '\r')
            read_char = getchar ();
        while (read_char != ' ' && read_char != '\n' && read_char != '\r'){
            c[++ len] = read_char;
            read_char = getchar ();
        }
        return len;
    }
}

#define vic(x) (((x) & 1) ? - 1 : 1)

const int V = 1e9, inf = 0x3f3f3f3f3f3f3f3fll;

int Luc[105], cnt;
int Fib[105];

__inline__ __attribute__ ((always_inline)) void INIT (){
    Luc[0] = 2;
    Luc[1] = 1;
    for (cnt = 1;Luc[cnt] <= V;++ cnt)
        Luc[cnt + 1] = Luc[cnt] + Luc[cnt - 1];
    -- cnt;
    // Fib[1] = 1;
    // for (int i = 2;i <= 56;++ i)
    //     Fib[i] = Fib[i - 1] + Fib[i - 2];
}

int ans;

struct node {
    int l, r;
    node (int _l_ = 0, int _r_ = 0){
        l = _l_;
        r = _r_;
    }
    __inline__ __attribute__ ((always_inline)) bool operator < (const node &oth) const {
        if (l == oth.l)
            return r < oth.r;
        return l < oth.l;
    }
};

set < node > s;

namespace CHECK {
    __inline__ __attribute__ ((always_inline)) void OUTPUT (){
        printf ("<%lld>", ans);
        int sum = 0;
        for (auto x : s){
            printf ("[%lld %lld]", x.l, x.r);
            for (int i = x.l;i <= x.r;i += 2){
                sum += Fib[i];
                // printf ("<<%lld>>", Fib[i - 1]);
            }
        }
        printf (">> %lld", sum);
        puts ("");
    }
}

__inline__ __attribute__ ((always_inline)) set < node > ::iterator find_right (int x){
    return s.upper_bound (node (x, inf));
}
__inline__ __attribute__ ((always_inline)) set < node > ::iterator find_contain (int x){
    auto it = find_right (x);
    if (it == s.begin ())
        return s.end ();
    -- it;
    if ((*it).r >= x)
        return it;
    return s.end ();
}
__inline__ __attribute__ ((always_inline)) set < node > ::iterator find_left (int x){
    auto it = find_right (x);
    if (it != s.begin ())
        -- it;
    if (it == s.end ())
        return it;
    if ((*it).r >= x && it != s.begin ())
        return -- it;
    if (it == s.begin () && (*it).r >= x)
        return s.end ();
    return it;
}

// __inline__ __attribute__ ((always_inline)) bool Check_first (node x){
//     return find_left (x.l) == s.end ();
// }

__inline__ __attribute__ ((always_inline)) int Cost (node x){ // self cost
    if (x.l <= 3)
        return ((x.r - x.l) >> 1);
    return x.r - x.l;
}

__inline__ __attribute__ ((always_inline)) int Cost_con (node x, node y){ // connect cost
    int las = x.r - 1;
    if (x.l <= 3)
        ++ las;
    if (y.l - las <= 2)
        return 1;
    return (y.l - las + 1) / 2;
}

__inline__ __attribute__ ((always_inline)) void Del (node x){
    if (x.l > x.r)
        return ;
    auto bel = find_contain (x.l);
    node tt = *bel;
    s.erase (bel);
    if (tt.l <= x.l - 2)
        s.insert (node (tt.l, x.l - 2));
    if (x.r + 2 <= tt.r)
        s.insert (node (x.r + 2, tt.r));
    auto pre = find_left (x.l);
    // printf ("del : %lld %lld\n", x.l, x.r);
    // printf ("before : "); CHECK::OUTPUT ();
    if (pre != s.end ())
        ans -= Cost_con (*pre, x);
    else
        ans -= Cost_con (node (1, 1), x);
    auto nex = find_right (x.r);
    if (nex != s.end ())
        ans -= Cost_con (x, *nex);
    // CHECK::OUTPUT ();
    if (pre != s.end () && nex != s.end ())
        ans += Cost_con (*pre, *nex);
    else
    if (nex != s.end ())
        ans += Cost_con (node (1, 1), *nex);
    // CHECK::OUTPUT ();
    ans -= Cost (x);
    // CHECK::OUTPUT ();
    // puts ("del end");
}
void Ins (node x){
    if (x.l > x.r)
        return ;
    auto pre = find_left (x.l), nex = find_right (x.r);
    // printf ("ins : %lld %lld\n", x.l, x.r);
    if (pre != s.end () && (*pre).r == x.l - 2){
        node tt;
        Del (tt = *pre);
        Ins (node (tt.l, x.r));
        return ;
    }
    if (nex != s.end () && (*nex).l == x.r + 2){
        node tt;
        Del (tt = *nex);
        Ins (node (x.l, tt.r));
        return ;
    }
    // printf ("ins : %lld %lld\n", x.l, x.r);
    // printf ("before : ");
    // CHECK::OUTPUT ();
    if (pre != s.end ())
        ans += Cost_con (*pre, x);
    else
        ans += Cost_con (node (1, 1), x);
    // CHECK::OUTPUT ();
    if (nex != s.end ())
        ans += Cost_con (x, *nex);
    if (pre != s.end () && nex != s.end ())
        ans -= Cost_con (*pre, *nex);
    else
    if (nex != s.end ())
        ans -= Cost_con (node (1, 1), *nex);
    ans += Cost (x);
    s.insert (x);
    // CHECK::OUTPUT ();
    // puts ("ins end");

}


void Insert (int v, int p){
    if (p < 1)
        return ;
    if (p == 1){
        Insert (v, 2);
        return ;
    }
    // printf ("<%lld %lld>\n", v, p);
    if (v == 1){
        set < node > ::iterator it;
        if ((it = find_contain (p)) != s.end ()){
            node tt = *it;
            if ((p & 1) == (tt.l & 1)){
                Del (tt);
                Ins (node (tt.l + 1, p - 1));
                Insert (1, tt.r + 1);
                Insert (1, tt.l - 2);
            } else {
                Del (tt);
                Ins (node (tt.l, p - 1));
                Insert (1, tt.r + 1);
            }
        } else
        if ((it = find_left (p)) != s.end () && (*it).r == p - 1){
            node tt = *it;
            Del (tt);
            Ins (node (tt.l, tt.r - 2));
            Insert (1, tt.r + 2);
        } else
        if ((it = find_right (p)) != s.end () && (*it).l == p + 1){
            // puts ("in");
            node tt = *it;
            Del (tt);
            Insert (1, tt.r + 1);
        } else
            Ins (node (p, p));
    } else {
        set < node > ::iterator it;
        if ((it = find_contain (p)) != s.end ()){
            node tt = *it;
            if ((p & 1) == (tt.l & 1)){
                Del (tt);
                Ins (node (tt.l, p - 2));
                Ins (node (p + 2, tt.r));
            } else {
                Insert (- 1, p + 1);
                Insert (1, p - 1);
            }
        } else {
            // exist prefix 
            it = find_right (p);
            node tt = *it;
            // CHECK::OUTPUT ();
            Del (tt);
            // CHECK::OUTPUT ();
            Ins (node (tt.l + 2, tt.r));
            int tl = tt.l - 1, u = p + 1;
            if ((u & 1) != (tl & 1))
                ++ u;
            Ins (node (u, tl));
            if (u != p + 1)
                Insert (1, p - 1);
        }
    }
}

__inline__ __attribute__ ((always_inline)) void WORK (){
    // int sum = 0, res = 0;
    for (int T = io::read (), x, y;T --;){
        io::read (x), io::read (y);
        ++ y;
        // sum += x * Fib[y];
        if (! x)
            goto put_ans;
        // Insert (x, y);
        // goto put_ans;
        {
            int v = x / abs (x);
            x = abs (x);
            // int sm = 0;
            for (int i = cnt;i > 1;-- i)
                if (Luc[i] <= x){
                    x -= Luc[i];
                    if (v > 0){
                        Insert (v, y + i);
                        Insert (v * vic (i) * vic ((y - i < 0 ? (i - y + 1) : 0)), abs (y - i));
                    } else {
                        Insert (v * vic (i) * vic ((y - i < 0 ? (i - y + 1) : 0)), abs (y - i));
                        Insert (v, y + i);
                    }
                    // res += v * Fib[y + i] + v * vic (i) * vic ((y - i < 0) ? (i - y + 1) : 0) * Fib[abs (y - i)];
                    // sm += Luc[i];
                }
            // printf ("%lld %lld\n", res, sm);
            for (int i = 0;i < 2;++ i)
                if (Luc[i] <= x){
                    x -= Luc[i];
                    if (v > 0){
                        Insert (v, y + i);
                        // if (y == 6)
                        //     printf ("%lld %lld : ", v * vic (i), abs (y - i)), CHECK::OUTPUT ();
                        Insert (v * vic (i) * vic ((y - i < 0 ? (i - y + 1) : 0)), abs (y - i));
                        // if (y == 6)
                        //     printf ("%lld %lld : ", v, y + i), CHECK::OUTPUT ();
                    } else {
                        Insert (v * vic (i) * vic ((y - i < 0 ? (i - y + 1) : 0)), abs (y - i));
                        // if (y == 6)
                        //     printf ("%lld %lld : ", v * vic (i), abs (y - i)), CHECK::OUTPUT ();
                        Insert (v, y + i);
                        // if (y == 6)
                        //     printf ("%lld %lld : ", v, y + i), CHECK::OUTPUT ();
                    }
                    // res += v * Fib[y + i] + v * vic (i) * vic ((y - i < 0 ? (i - y + 1) : 0)) * Fib[abs (y - i)];
                }
            // printf ("rest : %lld\n", x);
            if (! s.empty () && (*s.begin ()).l == 1)
                Del (node (1, 1)), Insert (1, 2);
        }
        put_ans : ;
        // CHECK::OUTPUT ();
        io::write (ans), puts ("");
    }
}

__inline__ __attribute__ ((always_inline)) void init (){
    s.clear ();
    ans = 0;
}

signed main (){

    GET_START

    INIT ();
    for (int T = io::read ();T --;)
        WORK (), init ();
    
    GET_END

    return 0;
}
/*
ex : 

in:
3
6
912254245 4
-1 46
-12 36
893871732 9
803228012 6
-2420954 6
1
84415313 5
8
968295352 9
61184346 7
461451639 3
678826278 4
108032410 3
515272015 4
879628340 3
85675803 7

out:
34
32
34
36
40
36
31
40
36
34
35
?

example :

input : 
1
19
1 1
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
-2 5
2 5
-1 8
-1 7
-1 6
-1 5
-1 4
-1 3
-1 2
-1 1

output : 
1
1
2
2
3
3
4
4
5
6
5
4
4
3
3
2
2
1

*/

// 1 2 1 2 1 2

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
10
1 1
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
-2 5

output:

1
1
2
2
3
3
4
4
5
6

result:

ok 10 tokens

Test #2:

score: 0
Accepted
time: 266ms
memory: 3956kb

input:

8954
6
912254245 4
-1 46
-12 36
893871732 9
803228012 6
-2420954 6
1
84415313 5
8
968295352 9
61184346 7
461451639 3
678826278 4
108032410 3
515272015 4
879628340 3
85675803 7
2
704915698 4
222546290 5
2
163176069 7
336268000 4
5
186521340 8
-1974 23
139542303 7
799104511 3
273699125 5
9
343587584 7...

output:

34
32
34
36
40
36
31
40
36
34
35
39
39
37
37
33
33
29
33
32
31
36
33
32
34
34
34
39
37
39
39
36
35
31
31
30
29
33
29
33
33
31
35
37
36
36
36
32
34
35
33
33
27
34
35
34
37
37
32
33
35
36
35
36
35
39
37
38
36
40
34
34
26
27
26
26
33
30
30
32
34
31
31
34
36
40
35
38
39
39
33
32
26
36
35
36
39
34
36
35
...

result:

ok 50000 tokens

Test #3:

score: 0
Accepted
time: 269ms
memory: 3940kb

input:

5000
10
87646505 4
505944264 8
135267060 1
540777610 5
-253 28
344447594 4
479770479 4
933432196 4
-110 34
-59556 15
10
424304491 7
-1441 26
578246113 9
611629791 9
622972757 5
7463054 9
88727249 8
612064742 3
972132616 7
-7158 17
10
380867349 9
687331729 6
-1 49
925692220 7
254331698 8
311959896 5
...

output:

30
37
33
34
35
36
35
35
38
38
33
31
40
36
41
36
40
37
43
40
38
37
36
34
37
39
36
35
35
34
29
27
31
34
34
36
38
38
34
40
32
33
34
35
38
38
34
36
41
38
32
34
33
35
35
37
36
39
35
39
32
33
32
29
28
35
36
33
33
35
28
33
36
38
38
36
38
38
40
37
34
40
32
33
38
36
34
37
37
38
31
34
35
38
36
35
41
34
37
40
...

result:

ok 50000 tokens

Test #4:

score: 0
Accepted
time: 482ms
memory: 3908kb

input:

500
100
971143861 51
254290089 45
-671917310 7
316460597 81
-135925838 16
664560198 24
-196394966 53
-4 116
247224643 79
-572127827 55
999961926 26
552687443 4
823117303 13
-1947759 76
786078222 14
-10194277 73
738218531 40
711188200 15
832296997 52
718819294 21
-818339217 13
921088669 96
911806021 ...

output:

73
64
68
90
86
82
83
83
88
88
93
88
90
90
87
89
83
84
85
85
93
100
98
96
100
100
100
94
98
101
108
100
103
101
93
94
92
91
94
94
94
97
98
100
95
96
97
102
102
104
100
100
99
96
93
93
92
95
95
94
91
97
97
97
97
97
94
101
97
95
94
95
101
95
92
98
99
94
93
99
100
107
95
98
99
99
96
100
107
105
98
100
1...

result:

ok 50000 tokens

Test #5:

score: 0
Accepted
time: 947ms
memory: 3928kb

input:

33
1989
817100821 1878
717398492 8724
900692749 823
81019595 8487
355336787 3771
-397881299 1739
374431780 8654
514122350 1974
708760527 5470
578962607 6539
-848563184 534
89705253 5470
140408613 3479
546580251 4827
780668444 3527
758968306 5286
-942163098 8059
944321738 200
-712356583 1983
97951298...

output:

977
4415
4437
4451
4472
4516
4532
4554
4575
4589
4708
4706
4728
4744
4754
4773
4965
4989
5695
6259
6283
6308
6286
6288
6301
6321
6337
6318
6363
6380
6385
6383
6532
6544
6530
6537
6556
6577
6608
6606
6602
6589
6685
6681
6696
6715
6764
6764
6756
6775
6593
6608
6615
6634
6618
6638
6640
6649
6662
6969
6...

result:

ok 50000 tokens

Test #6:

score: 0
Accepted
time: 1027ms
memory: 4704kb

input:

34
1074
559692196 21335
364304036 60868
970787415 24221
-861146625 57348
994445842 34803
701889798 47779
445005905 85180
962039724 33696
-996897910 51510
-531648501 84471
894774260 54227
-379779674 39270
374340661 13053
865776368 57856
-878578938 29375
169439795 13121
411579249 43238
913168855 32308...

output:

10709
30494
30516
32252
32277
32303
44475
44500
47396
47726
46185
50416
50440
48954
51090
51105
48856
48189
59817
59838
59856
59832
59841
59818
59842
59862
60261
60234
60252
60276
60147
60142
60162
61293
61298
61317
60347
60372
60391
56420
56435
56455
54419
54435
54413
54662
55193
55212
61947
61653
...

result:

ok 50000 tokens

Test #7:

score: 0
Accepted
time: 1181ms
memory: 5004kb

input:

4
16261
751534073 39922
-811551988 3528
23786917 98156
653995189 59466
541372309 10754
190430132 1350
982082781 49917
853822525 40089
871219811 16918
933963526 41068
823649240 62057
-681019612 46338
782858661 11609
149918638 14721
564271084 10695
215431264 47396
-227981235 74477
-574893135 67628
807...

output:

20002
38173
67299
67317
52756
52775
52790
52810
52834
52860
52877
54641
54660
54680
54663
53425
65242
68646
65012
67613
66843
68853
73572
73050
73026
73213
73823
73816
72497
72473
72455
72434
73605
72833
72846
72869
72890
72910
72753
72772
71069
71089
72212
72442
72459
74854
74854
74874
74851
74872
...

result:

ok 50000 tokens

Test #8:

score: 0
Accepted
time: 1190ms
memory: 4888kb

input:

1
50000
985810134 97326
235954146 2483
-304803167 16837
515074343 63440
607035441 7868
841115316 95040
609343124 69633
769128009 41482
-970957529 16718
191132999 17525
195543604 69977
931852038 81086
-726733931 40131
16796580 42064
-401491396 66052
963181903 34401
800628665 19493
632585172 34345
533...

output:

48701
48717
88937
72017
72033
72051
72070
61110
61150
49191
49211
49231
49882
49897
51661
51684
51702
51712
51727
51746
51762
51783
51804
51822
51963
54237
55227
55228
55532
58523
58542
58561
58577
58597
58613
57784
57801
57877
58241
58262
58278
58296
58316
57212
57236
57255
57228
60793
60815
60832
...

result:

ok 50000 tokens

Test #9:

score: 0
Accepted
time: 1372ms
memory: 14468kb

input:

1
50000
287588525 623530
-206242657 254623
619495165 819799
-997769683 119524
309830199 578636
65395198 490697
-404016357 152299
570997644 283393
249487976 394119
-676511624 667832
-105728195 311017
791001928 410389
9343310 642593
76085629 50462
280859452 183595
833659507 38252
641051357 995698
1236...

output:

311803
496230
594388
661911
639484
595534
595514
491884
491904
567861
609391
609406
609420
609436
573946
573970
661940
655552
655570
655589
625214
633388
633936
633954
633979
633958
633974
562776
562793
564819
567011
567033
585130
585148
586981
586998
587020
587038
587054
583561
580735
580753
592275...

result:

ok 50000 tokens

Test #10:

score: 0
Accepted
time: 1307ms
memory: 41672kb

input:

1
50000
261930062 1765420
-632054115 621659
-402254662 1693508
875890868 7030396
-214386744 4196700
-150246810 1667336
905104316 562816
-221775584 3399579
558669468 3167764
889433251 6761277
983743276 3625970
384284420 4360752
687090750 9386234
495238910 3834252
-498018388 5269349
-570910803 240766
...

output:

882750
1454607
1454584
4087091
5503913
5503892
5503910
5902450
5902469
5767931
5482584
4282337
5460274
5460290
6206229
6367236
7324966
7458805
7458783
7458762
6917749
6917771
6899615
7034049
7348067
7348088
7488932
7189253
7189230
7176294
7176318
7176339
7015655
7015669
7194307
7194326
7264350
71578...

result:

ok 50000 tokens

Test #11:

score: 0
Accepted
time: 1317ms
memory: 33260kb

input:

1
50000
95742021 2943328
134173239 8207571
14461040 5557686
640912426 8283899
-896178232 3000610
-12952353 5665491
144104799 4330415
615073113 4410213
611141047 2611142
-298534782 5791498
-976094022 6203175
117290894 8412832
-562308729 2454415
-825787492 7982328
-843007829 1774291
-213536348 2995529...

output:

1471701
4103842
4103857
4142042
5420556
6691578
6077960
6077979
6078001
6077977
6077960
6142441
6220778
6220752
6560792
6563305
5928170
6020350
6020373
6020351
5992336
5992308
6045767
5964281
6288179
6288200
6507805
6507826
6507844
6507863
6507839
6507856
6507875
6507894
6983673
6983693
6950910
6950...

result:

ok 50000 tokens

Test #12:

score: 0
Accepted
time: 1315ms
memory: 34548kb

input:

1
50000
543659567 7222392
-906037588 1698939
-142209983 1988790
-855966390 4301120
866468732 4413043
413021184 7874942
21146598 9901667
-228168390 9830436
981163358 1990412
549350329 523886
789175781 3458371
192380475 579961
129845367 1860740
-811608281 2596973
830591573 6206190
721187522 658332
730...

output:

3611233
6372935
6372914
6372891
4968232
5294524
6307900
6343497
5188166
5188180
5188200
5188217
5124213
5554884
5554904
5554924
5554945
5554965
5798917
6088531
6183318
6198711
6292638
6244320
6007977
6007995
6008012
6008032
5913964
5624962
5624984
5640720
5768228
5697704
5708965
5925600
5925619
5892...

result:

ok 50000 tokens

Test #13:

score: 0
Accepted
time: 1328ms
memory: 34632kb

input:

1
50000
348685788 7286553
471666882 1424426
725668751 5153493
550000773 6426622
912144364 6959726
695166645 9377372
-846328546 3571057
-928708432 3920863
25941400 1568697
760604386 1181996
-881437590 7932528
-662911252 6427699
270191454 6899335
-644054031 4707122
-144721974 7304894
879423618 564493
...

output:

3643314
3643332
3643352
3643367
3643388
4688816
5480012
5479988
5480009
5480029
6202421
6468410
6438234
6438207
6752002
6752025
6752046
6752022
6752045
6752030
6752047
6752020
6978641
6836779
7285653
7285669
7285647
7471414
7471395
7471412
7435839
7336825
7145729
7145745
7145758
7145775
7145793
7145...

result:

ok 50000 tokens

Test #14:

score: 0
Accepted
time: 1316ms
memory: 36468kb

input:

1
50000
385248878 9583482
51177917 1270651
-164405003 5294679
-952514277 69836
827737022 1636613
926182285 4228469
71903071 4645795
85487583 5766770
-935170441 2540702
202683082 4025128
214354456 696041
820525228 7197948
824238335 7350761
330033011 9587148
935404676 5413247
-768930535 7914435
-93604...

output:

4791782
4791800
6936178
7536564
7536584
7536613
7536631
5628297
6472153
6370505
6083217
6083235
6083252
6085107
5908368
6742863
6780898
6780920
6644968
6749203
6749218
6662257
6662281
6662253
6396445
6982596
6982618
6982636
6982654
6613374
6613345
6613319
6613338
6613359
6765659
6935150
6867491
6867...

result:

ok 50000 tokens

Test #15:

score: 0
Accepted
time: 1237ms
memory: 50508kb

input:

1
50000
954399632 178561677
-407170239 165336276
972752570 556821604
-369769271 24874214
794904681 223012822
-229451275 426009957
954513387 359904364
386028984 194900226
317916059 547184495
-77259368 359970537
-434752666 489431319
-390728596 428405237
773874306 90248639
458230982 660181773
708814799...

output:

89280884
95893560
285023543
355254542
355254561
420660368
420660392
420660412
415841877
448861564
448861542
448861516
411317718
462997815
462997833
463935172
467956753
481915470
619476196
718342904
687895499
687895514
687895492
682497356
682497374
711229186
724196555
698474359
698474379
698474354
69...

result:

ok 50000 tokens

Test #16:

score: 0
Accepted
time: 1242ms
memory: 49652kb

input:

1
50000
560701909 109431696
-138014713 103992860
7836785 166817938
-366667755 55796672
243153341 111119511
70770638 684906744
793868751 175382974
-528538232 193510529
487713309 683747073
898649913 796646536
772237542 354854761
796136303 703459362
943952069 796059442
809329326 206984733
-208019014 37...

output:

54715888
57435284
86128419
110226488
110226508
369270929
369270955
614969036
614389217
670259137
505813004
505813024
505813047
431878054
586776683
614788897
614788914
622235091
622235108
622235129
622235149
622235129
622235146
622235115
620449240
624080652
646183948
646183967
640541113
640541132
649...

result:

ok 50000 tokens

Test #17:

score: 0
Accepted
time: 1257ms
memory: 49844kb

input:

1
50000
865663622 887799776
358495082 402897881
780749020 281388246
65779650 867390660
606118400 795225251
-461946203 288185684
689682759 681014875
442761852 432671620
-966324749 152936264
100404978 166619273
-45114098 186044924
165053023 682837179
79767807 863095664
-65147699 531896144
858238243 86...

output:

443899929
443899950
443899970
443899988
443900005
501256082
501256101
501256124
565482089
508097619
555769252
555769271
555769286
630328632
630328647
630328621
630328640
630328654
630328677
641405712
641405727
649677895
598042971
598042991
647500039
598431495
590119441
597226620
610372673
598550331
...

result:

ok 50000 tokens

Test #18:

score: 0
Accepted
time: 1228ms
memory: 50120kb

input:

1
50000
526591162 334045721
719952421 955996693
636052425 985464256
-683181124 757533300
595709184 739008420
-1426526 194024755
-645489288 643374939
955682271 738992432
549525528 370095061
281955154 498719179
628465932 983673003
407708570 988373268
885170035 693888402
-288028971 201527323
-857992778...

output:

167022897
477998401
492732198
591963866
591963883
661974345
709791069
709783098
709783114
709783136
709783160
711237684
688685691
688685670
778678070
688799353
664560730
664560756
664560775
569274407
639006509
639006524
639006547
639006564
639006584
639006604
657761273
657761294
657761309
657761327
...

result:

ok 50000 tokens

Test #19:

score: 0
Accepted
time: 1254ms
memory: 50048kb

input:

1
50000
746003385 292973304
-745672936 162937277
475111307 540324650
957858281 6185874
394397969 77123801
-16485214 381375250
525232229 456122894
65924492 649921874
340511128 270840097
197437632 175084280
989385030 424618282
382039336 156680919
-698516859 345274464
383337672 448404467
105169873 6176...

output:

146486692
211504679
335180367
335180393
335180413
414655090
372554226
427352855
416286274
368408384
352656099
352656116
370706486
370706505
370706521
475240476
523017610
521721224
525420718
538080662
538080681
546986444
541687445
541687470
541687490
593904655
643481235
643481247
630018515
633102683
...

result:

ok 50000 tokens