QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#826990#9877. Segment Treeucup-team3519#TL 3617ms11424kbC++173.6kb2024-12-22 18:07:502024-12-22 18:07:52

Judging History

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

  • [2024-12-22 18:07:52]
  • 评测
  • 测评结果:TL
  • 用时:3617ms
  • 内存:11424kb
  • [2024-12-22 18:07:50]
  • 提交

answer

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

#define V vector
#define pb push_back
#define fi first
#define se second
#define all0(x) (x).begin(), (x).end()
#define all1(x) (x).begin() + 1, (x).end()

typedef long long LL;
typedef pair<int, int> pi;

void solve() {
    int n;
    cin >> n;
    V<int> l(1 << n + 1);
    V<int> r(1 << n + 1);
    V<V<pi>> e((1 << n) + 1);
    V<int> val(1 << n + 1), true_val(1 << n + 1);
    auto ini = [&](int id, int L, int R, auto dfs) -> void {
        e[L].pb({R, 0});
        e[R].pb({L, 0});
        l[id] = L, r[id] = R;
        if (L == R - 1) {
            return;
        }
        int mid = L + R >> 1;
        dfs(id * 2, L, mid, dfs);
        dfs(id * 2 + 1, mid, R, dfs);
    };
    ini(1, 0, 1 << n, ini);
    auto set_val = [&](int id, int v) -> void {
        int L = l[id], R = r[id];
        for (auto &[y, w] : e[L]) {
            if (y == R) w = v;
        }
        for (auto &[y, w] : e[R]) {
            if (y == L) w = v;
        }
        val[id] = v;
    };
    auto upd_val = [&](int id, auto upd) -> void {
        int L = l[id], R = r[id];
        set_val(id, true_val[id]);
        if (L != R - 1) {
            set_val(id, min(true_val[id], val[id * 2] + val[id * 2 + 1]));
        }
        if (id != 1) upd(id / 2, upd);
    };
    auto chg_true = [&](int id, int v) -> void {
        true_val[id] = v;
        upd_val(id, upd_val);
    };
    for (int i = 1; i <= (1 << n + 1) - 1; i++) {
        int t;
        cin >> t;
        chg_true(i, t);
    }
    V<int> disa((1 << n) + 1), timea((1 << n) + 1);
    V<int> disb((1 << n) + 1), timeb((1 << n) + 1);
    int cur = 1;
    int q;
    cin >> q;
    V<int> vertex;
    // queue<int> que;
    V<int> que;
    int top = 0;
    auto run = [&](int x, V<int> &dis, V<int> &time) -> void {
        que.clear();
        top = 0;
        dis[x] = 0, time[x] = cur;
        que.push_back(x);
        while (top != que.size()) {
            int x = que[top++];
            vertex.pb(x);
            if (x == 0) continue;
            int lo = x & -x;
            if (x - lo >= 0) {
                int y = x - lo;
                int w;
                for (auto t : e[x]) {
                    if (t.fi == y) w = t.se;
                }
                if (time[x - lo] != cur)
                    time[x - lo] = cur, dis[x - lo] = 2e9;
                dis[x - lo] = min(dis[x - lo], dis[x] + w);
                que.push_back(x - lo);
            }
            if (x + lo <= (1 << n)) {
                int y = x + lo;
                int w;
                for (auto t : e[x]) {
                    if (t.fi == y) w = t.se;
                }
                if (time[x + lo] != cur)
                    time[x + lo] = cur, dis[x + lo] = 2e9;
                dis[x + lo] = min(dis[x + lo], dis[x] + w);
                que.push_back(x + lo);
            }
        }
    };
    for (int i = 1; i <= q; i++) {
        cur++;
        int t;
        cin >> t;
        if (t == 1) {
            int j, x;
            cin >> j >> x;
            chg_true(j, x);
        } else {
            int s, t;
            cin >> s >> t;
            run(s, disa, timea);
            run(t, disb, timeb);
            int ans = 2e9;
            for (auto x : vertex)
                if (timea[x] == timeb[x]) {
                    ans = min(ans, disa[x] + disb[x]);
                }
            vertex.clear();
            cout << ans << "\n";
        }
    }
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    solve();
}

詳細信息

Test #1:

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

input:

3
7 1 14 3 9 4 8 2 6 5 5 13 8 2 3
10
2 0 1
2 0 4
2 4 6
2 4 8
2 3 5
1 6 30
2 3 5
2 4 6
1 1 10000000
2 0 8

output:

2
1
4
8
17
18
13
15

result:

ok 8 tokens

Test #2:

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

input:

1
7914575 2436426 4979445
199989
1 1 6190629
1 1 1407775
1 1 2804784
1 2 2631932
1 1 3078537
1 3 286918
1 2 3238506
1 3 3361868
1 2 9296263
1 3 4836991
1 3 2177068
1 3 4291757
1 1 594328
1 2 8996221
1 1 5531545
1 3 3575467
1 3 3206504
1 1 8344965
1 3 6045895
2 0 2
1 2 6248153
1 1 5797489
1 1 9766466...

output:

8344965
5684734
2756417
2512448
130126
7091295
7834895
6363152
6668726
4380822
8809904
4042733
8566868
8653391
3654574
7617913
8583126
4470761
4099069
2539201
7188565
8465921
4517278
1913351
7400947
5104744
1759308
6081288
3559555
3409112
3714298
8937580
4704960
5280672
9424416
1622556
2599805
18330...

result:

ok 1899 tokens

Test #3:

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

input:

1
3080713 6130142 8931932
199954
1 3 3859793
1 2 8302798
1 1 1363993
1 2 2817427
1 1 6031503
1 1 4197608
1 1 3453017
1 3 3258277
1 2 1243375
1 3 7997018
1 1 8659259
1 1 545422
1 1 1213295
1 2 9318329
1 2 1165990
1 1 3910911
1 2 9639614
1 2 3166127
1 1 2556789
1 1 2505213
2 1 2
1 1 8837030
1 1 996138...

output:

5671340
4103158
2278869
1251419
702774
1634200
9066441
3444042
4761391
1317349
996556
3444042
996556
996556
4884903
6746567
6746567
1389661
4920459
230651
935263
2028823
680623
1093324
1093324
680623
680623
369391
6136723
5192803
5192803
6136723
4301516
4578392
3566336
3566336
7599310
4756965
378391...

result:

ok 29717 tokens

Test #4:

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

input:

1
6313638 363583 8248153
199989
2 1 2
1 1 155990
1 2 4430056
2 0 2
2 1 2
1 1 6771887
1 1 9001299
2 0 1
1 3 2051074
2 1 2
2 0 1
1 1 3829876
2 0 1
1 3 8940076
2 1 2
2 0 1
2 0 2
2 0 2
1 1 2321211
1 2 8057327
2 0 2
1 1 553338
1 2 7877801
2 0 2
1 2 2505976
1 3 1153207
2 0 2
1 2 4561192
1 2 4540078
1 1 90...

output:

6677221
155990
4586046
4430056
2051074
4430056
4430056
8259932
4430056
3829876
3829876
2321211
553338
553338
5693285
4540078
4547501
5088001
1153207
3934794
1153207
3934794
3934794
3934794
7085662
3658305
3147631
3658305
6805936
3147631
3147631
853551
2267606
3727767
3727767
2645926
3727767
2645926
...

result:

ok 100061 tokens

Test #5:

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

input:

2
4716625 8732769 4896438 9294402 7273885 4137152 2249944
199996
1 1 5186587
1 4 7722585
1 5 3539426
1 5 1298070
1 6 8806800
1 1 4206062
1 6 6971489
1 5 8825000
1 5 3448517
1 6 9944200
1 1 3672387
1 2 1617483
1 5 8197902
1 6 4298339
1 5 6260453
1 2 3666548
1 3 9334704
1 3 5244559
1 3 2160729
1 6 944...

output:

5334226
9572097
4807948
733673
8100027
6139742
6091424
5926345
8623714
12325259
6201853
1162428
2792985
6816822
9147939
8703527
5455802
2767961
4607887
7567091
1326121
3115123
3452276
7483661
3901199
2876292
3890889
78252
9798360
2638886
8164525
6562024
7215100
4673524
5294603
9171516
5178543
904555...

result:

ok 2118 tokens

Test #6:

score: 0
Accepted
time: 29ms
memory: 3620kb

input:

2
1364796 5777257 6371509 2448237 9098057 7484260 6546327
199987
1 3 5999195
2 3 4
1 3 8887115
1 1 2734385
1 7 4638308
1 3 6026141
1 6 4213294
1 6 5557847
1 3 2560361
1 5 3524344
1 6 2074700
1 6 2999265
1 2 1130752
1 7 3252447
2 2 3
2 1 4
1 4 1415121
1 2 9989166
1 4 3857618
1 7 1787670
2 0 1
1 1 784...

output:

6546327
2999265
5182622
3857618
3857618
2560361
3687472
3687472
2623407
7097702
10955320
3857618
2419123
7980269
15666313
9307178
11416196
5371134
6559731
3730152
5371134
6877903
4359151
3280494
3826548
3826548
546054
2901939
6122499
1164580
4886291
2231873
4929939
10014378
1431973
5738696
3914548
1...

result:

ok 30271 tokens

Test #7:

score: 0
Accepted
time: 38ms
memory: 3756kb

input:

2
8987238 2085975 9756733 3937228 1094674 2515166 9606967
199961
2 0 1
1 4 3666395
1 3 6910698
2 0 2
1 7 8573254
2 0 2
2 1 4
1 5 3266966
2 2 3
1 1 2915552
1 1 4329051
2 0 3
1 5 4369037
1 2 6363300
2 2 3
2 1 3
2 0 2
1 1 4914198
1 3 1997323
2 0 2
2 0 4
1 4 1415720
1 4 1289499
1 2 750052
2 0 2
2 2 4
2 ...

output:

3180649
2085975
2085975
8005372
2515166
4601141
2515166
6884203
6363300
6363300
4914198
750052
1997323
3265218
4512489
4036874
4512489
4681644
4914198
3674754
1990038
5949064
5949064
1997323
5949064
2927673
4924996
3240280
1997323
2927673
5949064
1997323
8732393
3472087
2997143
5118510
6305731
19973...

result:

ok 100133 tokens

Test #8:

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

input:

3
1482396 5315709 8450176 919682 3898524 3571079 1589616 2035962 5516932 5891312 6849529 7354202 7031642 16502 9308215
199975
1 7 339038
1 13 5808906
1 4 3919992
1 5 9215343
1 11 3298396
1 8 5150388
1 5 8504301
1 8 6918145
1 3 9033980
1 6 5735807
1 13 4288323
1 10 8374520
1 10 7379361
1 10 4528048
1...

output:

16285940
5238493
5238493
22472855
4669470
9602957
8393079
10020309
10254346
9573978
8514546
1334143
5464242
3719349
3301995
7390632
14498
8915141
14146684
6366701
3961165
16556363
7660670
703615
6012909
8926254
2066592
119507
3915410
342821
5297748
4461720
14683484
6646771
9060221
16652253
5539517
2...

result:

ok 1998 tokens

Test #9:

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

input:

3
7876562 7918635 6176833 4520847 6020244 5083916 622852 1770395 1392360 8442457 9525646 7836026 7109198 1592189 2928475
199969
1 3 1211323
1 12 6475000
1 4 6251690
1 13 4588701
2 2 4
1 13 2830484
1 9 5455590
1 2 4199941
2 4 5
1 11 4237912
1 8 8616532
1 2 7013262
1 15 1447432
1 10 1885793
1 1 302428...

output:

6020244
4664659
6251690
2864338
12620842
4663182
2809904
3300986
4297387
491082
8535859
4663334
10090113
2286459
5010204
9102340
6155733
7634549
11501377
3479332
7732994
5676990
5079349
7705518
11300621
13032232
6363537
7777507
2257343
13773540
6235980
4805506
6429254
4494831
8735088
7368501
5269100...

result:

ok 29959 tokens

Test #10:

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

input:

3
6577234 7854127 1080391 5145959 8947475 6924960 2198194 754421 9124876 764427 1234813 50367 6595762 5221022 9057974
199974
2 1 4
1 5 5912881
2 2 4
1 7 1124351
2 4 7
2 5 7
2 4 5
1 13 2139694
2 0 5
1 8 6713651
2 1 6
1 15 7871410
2 6 8
2 6 8
2 2 5
1 9 4197528
1 5 6876249
1 12 618638
1 2 5353143
2 0 4...

output:

7899620
1999240
7425764
7476131
50367
7195566
13314177
1124351
1124351
2049607
5353143
2617878
3439555
2139694
9425004
1080391
764427
5353143
1124351
2315204
764427
1124351
10555137
2617878
5482720
5593182
15776159
7481960
4961955
7481960
10493849
4358369
10814204
5221022
6357609
5294962
2276892
435...

result:

ok 99699 tokens

Test #11:

score: 0
Accepted
time: 62ms
memory: 3636kb

input:

6
6200813 2937593 7123154 7432392 9485632 271055 259223 1031893 8048638 4986334 3959447 7363320 1413621 971860 1688778 3534103 8309348 230130 3140570 7936752 1761922 8489742 7183013 8868752 4570229 2227218 4385599 1790428 610780 2973050 8497517 4637452 5834054 4557274 3328810 6585387 7311801 2692566...

output:

9806870
5065647
15037432
13145568
31482337
16007715
11448517
4198846
14424470
4756010
16520128
23458763
14417200
14090570
17775435
7820363
12633290
19577002
11428882
9369697
17942414
10589716
5994180
17140937
21105217
11881698
5967192
10477168
12361991
24044637
17593684
7190071
14655343
13995199
112...

result:

ok 2058 tokens

Test #12:

score: 0
Accepted
time: 106ms
memory: 3580kb

input:

7
208987 6257203 4512956 1974263 7466498 9468423 6551425 8025642 1460368 9146922 9173596 5664587 8067577 7217016 8194745 4585407 1984961 6580223 3462232 193760 790658 2229250 8933709 6060280 7181674 9188343 4630270 7906634 8187194 39561 251177 1725833 1666120 6901270 215771 5217631 4006270 1208241 5...

output:

3869475
13512210
30831753
16777131
18157613
7799209
16418655
16834355
11233913
9439002
11895392
8486245
17514427
5239929
9024447
25793170
9402145
20292990
19648423
18663551
26892168
19151248
16842570
23919723
13148324
16524763
26362332
8088420
29585953
24226686
21833470
28872273
19230627
33057482
23...

result:

ok 29791 tokens

Test #13:

score: 0
Accepted
time: 80ms
memory: 3556kb

input:

5
3222700 7176601 6224055 516739 5171617 1268508 2696157 2454239 6709351 4394692 2724852 8563342 1700330 7116385 280977 2410391 1915147 3781971 1847297 8685269 4665247 7875727 2431681 4774265 7886062 2980001 3946628 8840197 9308213 6976676 6759729 9607250 8401956 5042380 2473955 7879691 6633057 4004...

output:

8658607
12392820
12472651
7891497
17934752
14518681
15159305
7712393
11243360
14137282
8840176
8120037
10876696
16782547
3993360
14584740
9171949
20134410
14555955
9500704
12709310
6727296
16467321
13920062
9903763
12520164
11184915
8150894
1726005
11240362
5804581
5215136
13489658
14979200
13943987...

result:

ok 100112 tokens

Test #14:

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

input:

6
2715015 4125069 7426809 5119556 3817715 7152194 6383444 9292189 2782757 4642390 1259245 6135118 5242820 4492024 737189 3355215 599304 2006282 6479920 7665678 9092673 4302756 3936021 3488492 7111119 4465680 6734895 3271099 8649255 7301068 1995950 8827335 6831957 8878347 5882007 2700746 4938868 2431...

output:

14439446
15839271
24155629
19803407
5457609
21201770
12598088
9894994
12250299
11547486
3758119
18896176
9720151
12690708
13667905
6323215
11800814
11464378
8474223
11012095
16030846
8497280
20275723
14681687
14459715
20030567
13216476
31727949
10987670
5229872
17391573
8421036
16981113
14763848
172...

result:

ok 1959 tokens

Test #15:

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

input:

7
1193318 1585549 3591542 3642730 9311737 5169742 4548888 5180738 5173771 2283841 222251 5708903 5558597 8820839 2301104 5839682 3064865 19893 2421309 896242 7602799 2615059 1784699 9976779 7065939 2937182 8041129 2984786 9035205 5678694 1083799 3139907 8782479 1228785 8669484 3457420 8640339 902341...

output:

13640772
3514555
24330523
23486119
8276235
13610929
25854302
2947173
18153773
24558762
22348615
9882581
22178680
8867622
4709400
19561415
6945960
13485784
10579909
25241187
20244974
11545126
9695517
7831470
15617215
19134270
19575059
14987822
11720636
11791410
24152753
17444119
10871219
12050555
131...

result:

ok 29770 tokens

Test #16:

score: 0
Accepted
time: 283ms
memory: 3588kb

input:

8
76650 4864837 9137349 6670132 4966494 4677550 8058163 1173654 3982903 3817112 9126850 9647417 4777800 8012329 40269 6209883 1418264 2190551 8348582 3345230 593377 5594990 7449618 1903736 2250643 1562894 6636744 5852241 2688206 3946795 9617397 6506600 7105004 3335691 6882874 2472287 5758581 6355787...

output:

20089109
25486332
20784877
14114783
24478296
16624223
14436820
25918740
2729194
21936267
5105087
18535175
27604936
3116109
17133668
20775894
20223131
13357407
5594990
23744816
18705835
18597002
34738063
14854916
17071001
22838269
16807476
14949208
11832259
9590343
13989886
22643551
24157306
10735068...

result:

ok 99877 tokens

Test #17:

score: 0
Accepted
time: 228ms
memory: 4448kb

input:

13
3157923 9182813 8665230 2587210 9805357 7039817 6574884 749368 2655185 1475138 4373954 9321972 7917543 7419023 939656 517151 1222648 8706252 5011851 1200879 305988 6738920 3502163 9341742 1121085 4596775 9359068 1120057 3983754 1913120 44697 1362561 3612677 6866623 7587308 5853965 5144126 9311557...

output:

39892162
43223686
22458354
24594794
16071926
41896911
35835368
32063777
39102493
34975060
39834114
31211656
28060733
31155097
31061859
30794902
27040374
20691693
38998781
14524125
38351943
46248536
48495554
10871827
31873278
41949151
18689931
39500692
21951194
36266541
39451140
34105784
25547425
274...

result:

ok 2002 tokens

Test #18:

score: 0
Accepted
time: 576ms
memory: 4144kb

input:

12
6067035 2938954 6840590 6137807 9147503 8650723 888251 5505957 8765284 4502287 4992036 5836067 2542420 1622884 5283837 8668679 4429487 5648746 1338257 178117 3846073 2103198 1180605 2668162 474378 911473 1218931 9702169 7841420 417607 507961 489498 6961025 5282169 7059367 3446598 7888251 6189651 ...

output:

34368615
35489282
18507911
25126041
42201360
32399497
19408654
24238386
37335806
22807389
48066799
22227561
26995581
29950279
38481021
23214337
44410541
37129653
13029319
34540333
27004066
18261942
26531428
27421829
28680715
29368837
27500352
16522223
18241756
38615220
31391976
29936536
26247078
179...

result:

ok 30240 tokens

Test #19:

score: 0
Accepted
time: 664ms
memory: 3760kb

input:

10
4233258 9706194 8950871 2343344 387904 8095649 7125982 5243185 2440577 6606129 2432003 8017427 6016448 2169208 6031045 4190983 928838 9268608 9294549 3563536 4323537 2502502 4376988 2664197 6666640 3469148 7796274 8142995 4258600 1501095 2754024 7492792 2097074 9973025 6951871 8372425 556602 2011...

output:

16717553
15038615
25783919
23223625
31822718
19214208
30923261
23492355
14724527
17529431
36204309
15682262
16442715
30639343
18201550
17486826
15388346
23979366
18559462
10205628
8004313
31500542
19261776
22574080
23569449
16469519
20318391
24721591
36555452
27666373
14969204
17686196
25896808
2042...

result:

ok 100076 tokens

Test #20:

score: 0
Accepted
time: 147ms
memory: 3768kb

input:

11
4130926 444807 409077 4433596 4452018 1006034 4726804 2553298 2006788 7856980 8443484 1624336 6887706 6695093 3193040 9151225 496223 1097969 7080292 2348834 9867761 9433687 6603007 6640820 3507875 9259403 8600064 3517293 4970364 4022532 5544118 1502496 8944055 3184655 9984871 3524656 3988289 1038...

output:

25719195
25592182
30429586
19323010
16102275
20814144
14156359
20809664
24463537
33794888
27338989
8282000
21614635
27097976
25580268
22590901
26090598
31633131
20156190
26784302
26175339
18667134
14427098
13256006
20980437
18881846
25137695
14549359
17908451
28745238
17240535
13938473
28625279
2051...

result:

ok 1924 tokens

Test #21:

score: 0
Accepted
time: 404ms
memory: 3828kb

input:

11
3669307 9783168 4946600 2609770 9433387 4480558 9671015 7575081 9919695 6352394 7006331 4427592 1786047 3728085 5794682 5228307 6429227 8902407 7885897 9937612 8142290 627401 7057572 462758 6010764 8444155 8733084 8134090 3804865 3300015 5144852 8192981 249328 6310956 1715012 4771928 5852585 1266...

output:

36112951
17306850
17508409
18219399
14202541
29307242
38514292
38773099
40883824
26163943
20180923
37540850
36921270
26671485
20897852
47516342
24145128
22774827
21960399
26380963
23378662
32984852
29579223
28067202
31779544
38136349
22014654
25025866
39040917
32916230
23116385
29053995
32373551
356...

result:

ok 30308 tokens

Test #22:

score: 0
Accepted
time: 1005ms
memory: 3936kb

input:

11
4129893 1101991 8476752 2805163 9962668 8569061 9149880 3255313 3029546 8444324 9484932 9764037 6517419 3862907 9495737 902310 5239569 172083 1957300 8833291 5699922 4067532 7723940 4109370 8454648 8141943 9947917 6888306 5075616 6675229 6766534 9725794 8970492 6838103 1537532 2178351 4334801 361...

output:

28599481
24650693
50423871
27565801
47694910
31432665
36946345
29382967
40833469
28397682
29819031
27583282
32864397
26221909
41257097
35745348
31038824
18175436
29724261
38849708
40661971
38790686
31290029
12937944
16780185
35591916
18835139
10696665
25836932
14282845
35223798
28213493
24578676
302...

result:

ok 99867 tokens

Test #23:

score: 0
Accepted
time: 512ms
memory: 7476kb

input:

15
6507299 4697140 1885533 3654208 9632884 4781948 6202020 4838558 1511245 7807141 781706 4573068 7324673 9993533 2279164 7404612 6782393 8564420 9720573 1361581 2827758 1644719 3876258 9692265 7427955 5624165 338836 1701320 1216361 9843909 1840914 8361427 9987400 3124895 2505068 4082498 2610653 290...

output:

29441406
33071936
44518188
25098196
39712368
35855234
48403934
33061493
54864524
29436922
31714779
30630263
30829930
41898906
34913664
45551629
27938106
32893515
45278651
44330590
45645525
23010139
42348614
60609467
27509413
51093209
33617135
39804196
17500001
35755063
33837256
27300893
24348469
395...

result:

ok 1936 tokens

Test #24:

score: 0
Accepted
time: 3617ms
memory: 11424kb

input:

16
8433991 4175390 4738438 3180407 5629290 2033862 2012665 7011974 2142223 6644520 1765362 5913035 5144867 9646634 5446902 730837 1684708 6642852 1713312 8753639 7868647 508130 6478108 447480 828947 5174181 4252716 1017649 2231716 3415202 2497959 4479089 9332648 7238017 2294133 81100 3793029 3509983...

output:

29439503
35629005
39170748
33114271
23019795
42716886
39418782
23374583
19697690
26300780
38441230
34697549
15511615
25469603
20690791
31062487
31471145
34810485
47826415
39254578
28636345
43536150
29101368
37718417
33689493
47180644
26801319
32186576
26718336
35308567
31260009
49276593
32630338
518...

result:

ok 30232 tokens

Test #25:

score: -100
Time Limit Exceeded

input:

17
4504535 5480894 7873685 209868 4813520 7683904 8723490 4026670 3396834 8847740 1755157 5328748 3022115 9303033 5573069 8553063 418270 5918485 2805152 6818965 1187089 4870270 4679382 3479808 9446256 4944056 6031405 2207940 4551392 8301594 9248084 3757077 7712637 5905488 4732528 8049591 4146068 617...

output:

31691679
49610149
39698592
27104982
42762194
54263586
52106767
31098219
49835303
40964975
30498165
40840129
50650726
44626513
39364304
47427165
8773080
69280018
40685040
29904623
38111981
44634425
50650928
34061068
39080261
21996396
53436088
38568665
34549812
46783092
52770865
47130451
40925715
4506...

result: