QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137890#6343. Bitaro's traveljajco#100 ✓343ms11516kbC++174.5kb2023-08-10 18:41:302024-07-04 01:32:01

Judging History

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

  • [2024-07-04 01:32:01]
  • 评测
  • 测评结果:100
  • 用时:343ms
  • 内存:11516kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 18:41:30]
  • 提交

answer

#include <ios>
#include <algorithm>
#include <vector>
#define INF 2'000'000'000
#define REP(i, n) for (int i=0; i<(n); ++i)
#define sz(A) (int(A.size()))
#define V std::vector
typedef long long ll;
typedef V <int> vi;
typedef V <ll> vll;
typedef V <bool> vb;
struct stfin{
    vi t;
    int comp;
    int noop;
    bool czymin; // tu bedzie translacja ze +1 !!!
    int op(int i, int j){
        if (czymin)
            return std::min(i, j);
        return std::max(i, j);
    }
    stfin(int n, int m, const vi &v){
        czymin=m;
        noop=m ? INF : -INF;
        comp=1;
        while (comp<n)
            comp<<=1;
        t.resize(comp<<1, noop);
        --comp;
        for (size_t i=0; i<v.size(); ++i)
            t[i+comp+1]=v[i]<0 ? noop : v[i]; // ???
        for (int i=comp; i; --i)
            t[i]=op(t[i<<1], t[(i<<1)+1]);
    }
    void baz(int x, int y, vi &dest, int i, int p, int k){
        if (p>y||k<x)
            return;
        if (p>=x&&k<=y){
            dest.emplace_back(i);
            return;
        }
        i<<=1;
        baz(x, y, dest, i, p, (p+k)>>1);
        baz(x, y, dest, i+1, (p+k+2)>>1, k);
    }
    int znaj(int x, int y, int w, bool czyost){
        ++x,++y;
        vi prz;
        baz(x, y, prz, 1, 1, comp+1);
        if (czyost)
            std::reverse(prz.begin(), prz.end());
        for (int i : prz)
            if (op(t[i], w)==t[i]){
                while (i<=comp){
                    i<<=1,i^=czyost;
                    if (op(t[i], w)!=t[i])
                        i^=1;
                }
                return i-comp-1; // shift +1 !!!
            }
        return -1; // brak!
    }
};
int main(){
    int n;
    scanf("%d", &n);
    vi poz(n);
    REP(i, n)
        scanf("%d", &poz[i]);
    auto odl=[&](int p, int k){
        if (p>k)
            std::swap(p, k);
        return poz[k]-poz[p];
    };
    vi lprp(n, -1),pprp(n, -1); // noop
    REP(i, n){
        if (i<n-1){ // my jestesmy lewym
            int d=odl(i, i+1),p=i+1,k=n-1;
            while (p<k){ // najw ze nie dosiega
                int l=(p+k+2)>>1;
                if (odl(i+1, l)<d)
                    p=l;
                else
                    k=l-1;
            }
            lprp[i]=p;
        }
        if (i){ // my jestesmy prawym
            int d=odl(i-1, i),p=0,k=i-1;
            while (p<k){ // najm ze nie dosiega
                int l=(p+k)>>1;
                if (odl(l, i-1)<=d)
                    k=l;
                else
                    p=l+1;
            }
            pprp[i]=p; // asserty?
        }
    }
    vll wyn(n, 0);
    {
        stfin stl(n, 0, lprp),stp(n, 1, pprp);
        REP(i, n){
            // zakladajac start w i chcemy wynik...
            ll w=0;
            int p=i,k=i; bool czyl=1; // po ktorej stronie przedzialu jestesmy
            while (p||k<n-1){
                if (czyl){
                    if (!p||(k<n-1&&odl(p, p-1)>odl(p, k+1))){
                        w+=odl(p, k+1);
                        czyl=0;
                        ++k;
                        continue;
                    }
                    // tutaj jestesmy po lewej i idziemy w lewo
                    int j=stl.znaj(0, p-2, k+1, 1);
                    //if (j<0)
                    //    j=0;
                    ++j; // teraz jest najdalszy ok
                    w+=odl(p, j);
                    p=j;
                }
                else{
                    if (k==n-1||(p&&odl(k, k+1)>=odl(k, p-1))){
                        w+=odl(p-1, k);
                        czyl=1;
                        --p;
                        continue;
                    }
                    // jestesmy po prawej i idziemy w prawo
                    int j=stp.znaj(k+2, n-1, p-1, 0);
                    if (j<0)
                        j=n;
                    --j;
                    w+=odl(k, j);
                    k=j;
                }
            }
            wyn[i]=w;
        }
    }
    auto ub=[&](int i){ // zakladamy ze istnieje jakis wiekszy od i
        int p=0,k=sz(poz);
        while (p<k){
            int l=(p+k)>>1;
            if (poz[l]>i)
                k=l;
            else
                p=l+1;
        }
        return p;
    };
    int q;
    scanf("%d", &q);
    while (q--){
        int p,s;
        scanf("%d", &p);
        if (p<poz[0])
            s=0;
        else if (p>=poz.back())
            s=sz(poz)-1;
        else{
            // pierwszy wiekszy
            int i=ub(p);
            // [i]>p
            s=poz[i]-p<p-poz[i-1] ? i : i-1;
        }
        ll w=abs(p-poz[s])+wyn[s];
        printf("%lld\n", w);
    }
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

2000
154914587 154914588 154914591 154914592 154914594 154914596 154914598 154914599 154914601 154914603 154914608 154914610 154914612 154914615 154914618 154914619 154914621 154914622 154914626 154914627 154914631 154914633 154914636 154914638 154914640 154914641 154914642 154914644 154914645 15491...

output:

809906250

result:

ok 1 number(s): "809906250"

Test #2:

score: 5
Accepted
time: 2ms
memory: 4080kb

input:

2000
356563033 356563037 356563039 356563041 356563043 356563045 356563048 356563050 356563051 356563052 356563054 356563055 356563057 356563060 356563061 356563062 356563065 356563067 356563069 356563074 356563076 356563077 356563079 356563080 356563082 356563085 356563086 356563090 356563091 35656...

output:

722242888

result:

ok 1 number(s): "722242888"

Test #3:

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

input:

2000
24477976 24477978 24477981 24477982 24477986 24477988 24477990 24477992 24477993 24477996 24477998 24477999 24478001 24478002 24478003 24478005 24478007 24478008 24478009 24478011 24478012 24478013 24478015 24478016 24478017 24478019 24478020 24478022 24478024 24478026 24478029 24478031 2447803...

output:

795269579

result:

ok 1 number(s): "795269579"

Test #4:

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

input:

2000
118383953 118383958 118383960 118383964 118383966 118383970 118383971 118383972 118383974 118383976 118383977 118383978 118383979 118383981 118383982 118383983 118383986 118383987 118383989 118383990 118383991 118383993 118383994 118383996 118383998 118383999 118384000 118384002 118384006 11838...

output:

633902161

result:

ok 1 number(s): "633902161"

Test #5:

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

input:

2000
272693597 272693671 272693681 272693702 272693821 272693831 272693847 272693875 272693993 272694064 272694229 272694559 272694705 272694761 272694801 272694938 272695137 272695221 272695495 272695544 497465806 497465807 497465809 497465811 497465813 497465815 497465816 497465817 497465819 49746...

output:

224780330

result:

ok 1 number(s): "224780330"

Test #6:

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

input:

2000
164199708 164199714 164199741 164199803 164199830 164199964 164200182 164200363 164200417 164200604 164200739 164200758 164200777 164201008 164201058 164201062 164201119 164201206 164201308 164201582 568938433 568938436 568938440 568938442 568938446 568938448 568938449 568938452 568938454 56893...

output:

404746823

result:

ok 1 number(s): "404746823"

Test #7:

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

input:

1
964813969
1
24961702

output:

939852267

result:

ok 1 number(s): "939852267"

Test #8:

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

input:

1
492812692
1
492812692

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

1
819738491
1
871545564

output:

51807073

result:

ok 1 number(s): "51807073"

Test #10:

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

input:

1
964813971
1
925278587

output:

39535384

result:

ok 1 number(s): "39535384"

Test #11:

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

input:

2
253257833 492812697
1
801030938

output:

547773105

result:

ok 1 number(s): "547773105"

Test #12:

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

input:

10
122861190 170244470 313637646 547293542 557767683 701410141 705452393 819738518 859150721 987518805
1
857449755

output:

1602648112

result:

ok 1 number(s): "1602648112"

Test #13:

score: 5
Accepted
time: 2ms
memory: 3828kb

input:

2000
346838 1137625 2006182 2714727 3062547 3877790 4774903 5016683 5100124 5947146 6363889 7142496 8219943 9913673 10499786 10641688 10929569 11277685 11325053 11977547 12601991 12646876 13722054 14836426 15008615 15250796 16045457 17235758 17556322 17685977 18102009 19184164 19263658 19974844 2038...

output:

1654008616

result:

ok 1 number(s): "1654008616"

Test #14:

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

input:

2000
743982 1493878 1718132 1810575 1882146 2552776 2611689 3114975 3229588 3341359 3699120 3840597 3904572 5058917 6038144 6194653 6618139 6786522 8387028 8443750 9643914 9829181 10446710 10816676 11402658 12787879 13130024 13352051 13946478 14160206 14209716 14474473 14716259 14983734 15687019 165...

output:

1421041440

result:

ok 1 number(s): "1421041440"

Test #15:

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

input:

2000
303288 1146965 1808284 2456179 2479090 2692039 2724480 3624997 3642488 4829238 4981072 5161924 7384691 8030369 9147077 10341325 10424498 10772436 11533204 12219489 12219994 12527510 13411498 13805137 14640093 14743330 15382882 16704507 16934318 17667539 17748510 18253649 19219338 20280530 20297...

output:

1982070571

result:

ok 1 number(s): "1982070571"

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #16:

score: 10
Accepted
time: 178ms
memory: 11204kb

input:

200000
3362993 3362996 3362997 3363002 3363005 3363008 3363009 3363011 3363013 3363015 3363017 3363019 3363022 3363024 3363026 3363030 3363032 3363033 3363035 3363036 3363038 3363040 3363043 3363044 3363045 3363047 3363048 3363049 3363050 3363052 3363053 3363054 3363056 3363057 3363060 3363061 33630...

output:

1253123755

result:

ok 1 number(s): "1253123755"

Test #17:

score: 10
Accepted
time: 177ms
memory: 11448kb

input:

200000
49463 49465 49466 49469 49470 49471 49473 49474 49475 49476 49479 49482 49484 49485 49486 49488 49490 49492 49495 49503 49506 49509 49511 49512 49515 49517 49519 49521 49522 49523 49528 49530 49531 49534 49535 49536 49537 49538 49539 49544 49547 49548 49550 49551 49554 49555 49558 49559 49562...

output:

1688511141

result:

ok 1 number(s): "1688511141"

Test #18:

score: 10
Accepted
time: 175ms
memory: 11268kb

input:

200000
2519385 2519387 2519389 2519391 2519392 2519393 2519395 2519397 2519399 2519400 2519401 2519402 2519407 2519408 2519409 2519414 2519417 2519421 2519422 2519425 2519426 2519427 2519429 2519430 2519433 2519435 2519437 2519440 2519441 2519443 2519444 2519445 2519447 2519448 2519450 2519455 25194...

output:

1501931987

result:

ok 1 number(s): "1501931987"

Test #19:

score: 10
Accepted
time: 175ms
memory: 11260kb

input:

200000
7436901 7436905 7436907 7436908 7436909 7436913 7436916 7436917 7436920 7436921 7436922 7436923 7436925 7436927 7436931 7436933 7436936 7436938 7436941 7436944 7436947 7436948 7436950 7436952 7436954 7436956 7436957 7436959 7436961 7436963 7436965 7436966 7436969 7436971 7436973 7436974 74369...

output:

1771935938

result:

ok 1 number(s): "1771935938"

Test #20:

score: 10
Accepted
time: 171ms
memory: 11516kb

input:

200000
45000691 45000693 45000695 45000696 45000698 45000700 45000701 45000703 45000705 45000708 45000710 45000711 45000712 45000716 45000717 45000718 45000720 45000721 45000722 45000723 45000725 45000727 45000728 45000729 45000731 45000733 45000735 45000736 45000737 45000739 45000741 45000743 45000...

output:

1064147063

result:

ok 1 number(s): "1064147063"

Test #21:

score: 10
Accepted
time: 176ms
memory: 11276kb

input:

200000
5250516 5250518 5250520 5250522 5250524 5250525 5250527 5250529 5250530 5250533 5250535 5250536 5250538 5250540 5250541 5250543 5250545 5250547 5250549 5250550 5250551 5250553 5250555 5250556 5250558 5250560 5250561 5250564 5250567 5250568 5250570 5250573 5250574 5250578 5250581 5250582 52505...

output:

1802633713

result:

ok 1 number(s): "1802633713"

Test #22:

score: 10
Accepted
time: 167ms
memory: 11260kb

input:

200000
61827212 61827216 61827221 61827222 61827223 61827225 61827226 61827228 61827231 61827232 61827235 61827236 61827238 61827240 61827241 61827243 61827244 61827246 61827248 61827250 61827253 61827254 61827256 61827257 61827260 61827261 61827263 61827265 61827266 61827268 61827272 61827273 61827...

output:

1231202945

result:

ok 1 number(s): "1231202945"

Test #23:

score: 10
Accepted
time: 113ms
memory: 11324kb

input:

200000
6461 16888 21388 22690 26075 28748 37518 43692 54726 63506 68089 68214 74411 76830 77202 77258 78577 78980 81554 82694 85919 86290 87790 95906 99082 128500 129722 130180 133703 134802 162914 166030 166333 173867 178199 180455 180824 191455 196406 198191 198195 201127 208417 211429 212076 2127...

output:

1134619264

result:

ok 1 number(s): "1134619264"

Test #24:

score: 10
Accepted
time: 116ms
memory: 11340kb

input:

200000
6073 17506 26350 26659 27386 27891 29276 32363 32396 33218 35965 38925 41070 45188 46001 49478 55459 56076 61468 61901 63436 65020 69571 69610 72566 89021 90100 95567 100955 101172 104374 113982 116752 119237 121670 123692 126841 127028 129299 141274 144123 144537 146491 147818 149993 151385 ...

output:

1627978238

result:

ok 1 number(s): "1627978238"

Test #25:

score: 10
Accepted
time: 112ms
memory: 11336kb

input:

200000
1171 8640 29342 30040 31919 37016 39089 47080 47657 48123 55898 56221 56630 64288 67165 69389 73318 77445 78536 78736 79476 80766 87340 88547 90375 91725 94350 100361 103655 109091 113475 131608 133798 143346 157085 157944 161804 180736 180739 185261 189093 194336 205064 205947 208142 209193 ...

output:

1567112510

result:

ok 1 number(s): "1567112510"

Test #26:

score: 10
Accepted
time: 113ms
memory: 11348kb

input:

200000
198 11195 13692 31357 31516 32440 36297 43191 43298 47998 54392 59762 87583 89610 89934 90101 96327 98356 98634 98985 101712 105244 110557 117162 124917 132969 135196 141775 143285 151905 161407 168205 168559 169770 172030 172771 173167 179504 183511 194428 198897 201792 205391 207070 224933 ...

output:

1466018232

result:

ok 1 number(s): "1466018232"

Test #27:

score: 10
Accepted
time: 116ms
memory: 11336kb

input:

200000
393 4968 13055 13360 18315 21172 39005 44122 48418 54690 60392 68336 69427 73082 73123 73572 80328 83757 88893 104839 106818 109726 117559 121645 132682 136461 137786 150162 152637 174063 175425 177640 179369 184476 185659 186554 205885 206271 207387 211714 222765 228223 229195 247977 258920 ...

output:

1442534979

result:

ok 1 number(s): "1442534979"

Test #28:

score: 10
Accepted
time: 303ms
memory: 11448kb

input:

200000
0 4 5 11 13 16 20 21 22 24 28 30 32 35 38 40 41 45 46 54 55 57 58 61 65 66 75 76 78 79 81 87 95 97 100 104 108 114 117 122 125 129 131 133 134 137 138 141 142 143 149 151 153 155 157 159 162 166 170 173 176 183 184 185 186 191 195 200 202 203 205 206 207 210 215 218 220 223 227 233 236 240 24...

output:

1100443362

result:

ok 1 number(s): "1100443362"

Test #29:

score: 10
Accepted
time: 343ms
memory: 11340kb

input:

200000
1 2 5 8 10 11 12 14 15 19 22 23 30 34 36 40 43 45 51 54 55 57 59 63 65 71 77 79 82 84 89 95 103 110 111 113 115 116 119 120 123 124 128 129 139 145 147 150 152 156 158 159 163 164 169 170 172 177 180 182 184 188 194 196 197 198 201 204 218 219 222 223 226 228 230 234 236 238 240 241 243 246 2...

output:

1092131990

result:

ok 1 number(s): "1092131990"

Test #30:

score: 10
Accepted
time: 304ms
memory: 11352kb

input:

200000
5 7 11 14 16 17 20 22 24 28 29 31 32 33 35 40 46 53 58 61 62 63 67 72 75 76 77 79 84 86 89 92 93 99 100 102 105 107 109 111 114 119 122 124 125 126 128 131 132 135 137 143 145 147 150 151 155 160 161 163 168 172 173 175 177 181 182 184 187 190 192 196 197 210 213 214 217 218 222 225 226 229 2...

output:

1098945476

result:

ok 1 number(s): "1098945476"

Subtask #3:

score: 30
Accepted

Test #31:

score: 30
Accepted
time: 138ms
memory: 11260kb

input:

200000
9 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181...

output:

200107
999999991
202154
346046
379455
269768
313076
381369
366120
265794
363817
348433
342292
260613
302587
332141
311760
281789
345769
366459
218270
221124
225466
313243
322095
332977
281351
224651
257342
259560
206246
231269
316285
371811
394056
382486
202443
357928
359464
357158
354417
368006
326...

result:

ok 200000 numbers

Test #32:

score: 30
Accepted
time: 138ms
memory: 11516kb

input:

200000
9 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181...

output:

200107
999999991
214953
203176
263561
315480
345760
288169
362438
292732
224749
214412
299705
264321
211653
248956
233685
236984
306911
206078
236282
203851
343753
216241
366274
383291
227991
214501
208691
248280
282497
201835
302961
384269
339680
249381
395777
201468
253356
249808
316046
217202
336...

result:

ok 200000 numbers

Test #33:

score: 30
Accepted
time: 142ms
memory: 11516kb

input:

200000
0 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172...

output:

200098
1000000000
200809
332026
340583
320747
327951
280466
335577
392195
262246
384764
279889
296343
206119
282306
382710
389025
369823
307624
382688
379733
319319
266016
316382
273064
390368
312448
210119
335070
205821
256717
233293
235566
200495
327143
380534
281176
293482
211483
317727
234273
21...

result:

ok 200000 numbers

Test #34:

score: 30
Accepted
time: 151ms
memory: 11348kb

input:

200000
9 109 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182...

output:

200108
999999991
398935
342885
372407
268595
300075
371409
353777
253452
348389
342780
337158
251989
290087
326120
302345
280025
337667
354788
207572
219029
219537
312936
309352
322171
278794
215577
238037
256322
203016
217393
307132
363991
389419
367602
395084
350195
342074
354917
333585
353297
307...

result:

ok 200000 numbers

Test #35:

score: 30
Accepted
time: 147ms
memory: 11264kb

input:

200000
9 109 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182...

output:

200108
999999991
399468
396515
254881
299064
337551
286690
358899
284471
214726
211350
282076
246510
393082
233179
230206
229157
287918
388371
216198
398026
326810
396152
352980
362859
207997
211382
207339
245208
279636
387108
287348
370846
326052
238182
377891
390157
238807
236535
303642
200314
331...

result:

ok 200000 numbers

Test #36:

score: 30
Accepted
time: 142ms
memory: 11392kb

input:

200000
0 100 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173...

output:

200099
1000000000
400101
324295
330652
307228
323659
266967
326296
376082
254255
366054
279702
288698
394108
278540
364606
386882
367087
297310
377645
367863
306592
251530
299280
261817
381250
300696
395926
325927
202038
238905
217436
228164
390510
326430
365953
266838
281214
396382
308060
213534
39...

result:

ok 200000 numbers

Test #37:

score: 30
Accepted
time: 27ms
memory: 3712kb

input:

1
752274513
200000
0
1000000000
3062543
353824670
471209108
300038685
972824952
279683767
647873489
455102926
383075404
304797585
248935750
197299138
525182332
495865149
664082073
708206991
86351822
501205423
604244437
984963897
681547274
314559829
730183804
245318283
760613011
309037613
514660147
8...

output:

752274513
247725487
749211970
398449843
281065405
452235828
220550439
472590746
104401024
297171587
369199109
447476928
503338763
554975375
227092181
256409364
88192440
44067522
665922691
251069090
148030076
232689384
70727239
437714684
22090709
506956230
8338498
443236900
237614366
115943118
686592...

result:

ok 200000 numbers

Test #38:

score: 30
Accepted
time: 20ms
memory: 3924kb

input:

1
73
200000
0
1000000000
10
72
125
39
37
127
54
106
35
45
65
95
80
77
45
50
6
54
43
102
2
97
92
59
65
15
16
6
97
31
15
102
110
95
68
0
72
36
101
143
94
97
142
19
15
70
145
22
41
7
35
51
78
141
13
4
143
49
34
37
134
132
14
24
111
19
1
31
113
96
106
34
74
74
27
31
37
96
84
62
47
34
33
133
15
78
120
72...

output:

73
999999927
63
1
52
34
36
54
19
33
38
28
8
22
7
4
28
23
67
19
30
29
71
24
19
14
8
58
57
67
24
42
58
29
37
22
5
73
1
37
28
70
21
24
69
54
58
3
72
51
32
66
38
22
5
68
60
69
70
24
39
36
61
59
59
49
38
54
72
42
40
23
33
39
1
1
46
42
36
23
11
11
26
39
40
60
58
5
47
1
38
7
14
51
73
46
61
8
45
59
33
51
70...

result:

ok 200000 numbers

Test #39:

score: 30
Accepted
time: 147ms
memory: 11348kb

input:

200000
67 98 181 270 354 429 496 561 572 671 696 787 856 935 1022 1065 1091 1129 1188 1256 1296 1316 1386 1388 1462 1495 1513 1563 1621 1665 1760 1790 1812 1855 1918 1971 1990 2087 2137 2234 2313 2329 2423 2501 2585 2642 2695 2795 2893 2990 3085 3095 3185 3279 3315 3327 3377 3454 3493 3553 3617 3662...

output:

10100896
999999933
14574238
13002253
19727669
11009705
15218711
13678079
18071902
18516120
13910578
13098664
12765541
19245270
18563620
19531507
17598566
16639075
18337352
14028651
11260968
14138243
18288313
14125110
18034945
17514062
15950989
17179910
10723293
17833318
17175872
16182912
17058697
17...

result:

ok 200000 numbers

Test #40:

score: 30
Accepted
time: 142ms
memory: 11452kb

input:

200000
56 155 200 281 359 390 450 481 486 561 643 655 687 770 843 857 928 931 1004 1035 1106 1148 1201 1207 1247 1331 1388 1433 1518 1596 1630 1710 1803 1847 1935 2019 2040 2067 2140 2207 2234 2319 2361 2392 2443 2470 2546 2603 2655 2715 2721 2724 2742 2779 2863 2959 3018 3036 3133 3161 3196 3280 33...

output:

10099479
999999944
19666002
16920295
13752604
11237232
19892723
18057072
10132053
19106970
13451830
15568318
15143014
12685979
14553706
17171792
16421878
16935289
17820408
17376117
11606158
16571323
18078448
12756245
18533085
13983125
13783662
10775618
18333595
12873639
11112803
11508217
12750699
19...

result:

ok 200000 numbers

Test #41:

score: 30
Accepted
time: 149ms
memory: 11448kb

input:

200000
48 119 162 164 193 289 342 439 454 541 586 614 653 672 735 772 786 871 952 1005 1063 1155 1247 1255 1291 1317 1403 1497 1570 1669 1709 1734 1811 1818 1890 1938 2031 2046 2075 2087 2136 2149 2245 2325 2413 2426 2433 2458 2555 2600 2624 2672 2678 2760 2807 2847 2921 3012 3090 3109 3126 3185 327...

output:

10112306
999999952
15379916
16182543
13637759
16513331
16117808
15650914
18162842
15981756
12787755
17190160
13475260
13206244
11233290
11665342
13711600
17818541
14312433
14616449
11260658
10500451
14096289
12527756
12002654
18365270
11016139
13475840
19600093
15337066
14266423
16260782
20008879
15...

result:

ok 200000 numbers

Subtask #4:

score: 55
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #42:

score: 55
Accepted
time: 213ms
memory: 11276kb

input:

200000
1450443 1450444 1450448 1450449 1450450 1450452 1450453 1450456 1450458 1450459 1450460 1450463 1450464 1450466 1450467 1450469 1450472 1450474 1450475 1450481 1450483 1450484 1450486 1450487 1450488 1450490 1450494 1450496 1450497 1450499 1450500 1450504 1450505 1450507 1450509 1450510 14505...

output:

998839213
998549557
1744864596
1676899447
1733565616
1169302664
1448927904
1256309782
1887654139
1712264757
1559893678
1866855405
1080696270
1649302666
1436276985
1524832600
1183234463
1672500251
1719062355
1896398607
1493223443
1005640499
1477249503
1314758613
1806353065
1806981797
1101644645
15926...

result:

ok 200000 numbers

Test #43:

score: 55
Accepted
time: 228ms
memory: 11388kb

input:

200000
363811 363821 363823 363826 363828 363831 363833 363835 363838 363840 363844 363849 363851 363853 363854 363857 363859 363861 363863 363864 363865 363867 363868 363871 363872 363873 363874 363876 363877 363879 363880 363882 363883 363884 363885 363887 363890 363891 363892 363897 363899 363900...

output:

997925625
999636189
1979819226
1103369998
1928633213
1098957197
1583998589
1282386874
1185495646
1298383114
1521065547
1299954973
1333550199
1562659329
1557299540
1004241777
1298845131
1925524270
1979789983
1182264045
1627856018
1682630330
1818635431
1922029368
1108395775
1695608227
1490277970
10483...

result:

ok 200000 numbers

Test #44:

score: 55
Accepted
time: 231ms
memory: 11388kb

input:

200000
24110889 24110890 24110891 24110893 24110894 24110897 24110898 24110900 24110901 24110903 24110904 24110906 24110907 24110909 24110910 24110912 24110913 24110915 24110918 24110920 24110921 24110922 24110925 24110927 24110928 24110930 24110931 24110934 24110935 24110937 24110938 24110941 24110...

output:

999990121
975889111
1383181953
1585644060
1544716890
1149961416
1539393062
1692471633
1702298985
989814515
1549969862
1250579656
1689330857
1845846381
1842534129
1068592525
1655270051
1867560161
1190172438
995722748
1698385583
1661668652
1841115481
1853677955
1085706252
1842006792
1231483298
1676454...

result:

ok 200000 numbers

Test #45:

score: 55
Accepted
time: 28ms
memory: 3708kb

input:

1
266916179
200000
0
1000000000
353528026
13080561
228649488
163435909
131976100
468940062
530752844
122296975
165618465
449322833
314380195
98133703
45645827
455628716
500847404
180736226
425683879
201858137
302080250
444834662
378988518
292288039
92042730
67612198
101702837
374608587
70373971
4116...

output:

266916179
733083821
86611847
253835618
38266691
103480270
134940079
202023883
263836665
144619204
101297714
182406654
47464016
168782476
221270352
188712537
233931225
86179953
158767700
65058042
35164071
177918483
112072339
25371860
174873449
199303981
165213342
107692408
196542208
144713264
1460147...

result:

ok 200000 numbers

Test #46:

score: 55
Accepted
time: 154ms
memory: 11196kb

input:

200000
3020 8418 19658 19967 22583 25105 28261 30251 30743 36081 38104 42878 42926 44837 46084 47192 48981 49152 55068 55464 56246 62326 67130 67856 102474 104056 111862 117338 118414 119434 125722 128152 132014 136289 141339 150527 150706 154084 157353 159828 167697 172144 173080 181428 183492 1961...

output:

999989605
999996980
1065708693
1621512003
1312636366
1178843019
1577142083
1229389315
1008049207
1023256900
1239212909
1783508828
1605392989
1011896759
1562723234
1906891576
1466606843
1179403919
1958311782
1412806106
1106282449
1774304903
1302515913
1271843306
1180650816
1956891742
1962420814
14523...

result:

ok 200000 numbers

Test #47:

score: 55
Accepted
time: 171ms
memory: 11348kb

input:

200000
10199 30315 38613 39597 41132 45353 57080 57817 62548 65373 66574 70142 76348 80331 83125 83137 84189 90213 119422 124426 125306 126159 127699 130431 139881 149283 154308 166553 168654 170493 174189 175550 189739 204927 205241 205790 206428 209122 212647 214239 216691 221934 228357 228497 231...

output:

999998842
999989801
1796862407
1697559665
1453736497
1654918064
1336023383
1986900899
1494604217
1467735813
1195072388
1713969166
1302562702
1406810069
1649666717
1729488762
1140203915
1648493777
1791688486
1125647892
1937943262
1643716908
1800966284
1501879192
1932850762
1202329832
1743419357
19650...

result:

ok 200000 numbers

Test #48:

score: 55
Accepted
time: 170ms
memory: 11340kb

input:

200000
207 4089 6687 7911 10551 13335 14871 16713 17205 25105 25261 32036 34859 37521 42696 43145 44368 44388 47089 54354 57299 62300 62514 63383 66284 80444 80647 84603 85837 90880 91789 92225 115757 151557 180023 183244 187277 217732 222207 231570 255796 274455 277739 279540 280678 284950 289537 2...

output:

999999363
999999793
1174471243
1650862215
1268541414
1004458426
1687710492
1391572243
1920485088
1617850749
1806901694
1857027564
1966909691
1661771509
1799896240
1875421467
1820123337
1398127438
1522512806
1976869681
1782118441
1302230879
1969174192
1779394759
1317924692
1242078197
1203550858
19583...

result:

ok 200000 numbers

Test #49:

score: 55
Accepted
time: 330ms
memory: 11516kb

input:

200000
3 6 15 16 18 20 22 25 27 31 33 36 37 40 49 54 55 57 58 61 64 66 69 71 75 76 78 79 83 84 86 94 95 97 101 102 104 106 108 112 114 116 117 118 120 123 127 128 130 131 133 134 135 137 139 144 148 152 155 156 157 164 167 169 178 180 183 188 190 192 194 197 200 202 205 212 213 214 221 223 225 227 2...

output:

800199991
999999997
852198273
888863204
830273657
1160054971
803192695
913922103
1125174443
1168032481
1090556769
1149181287
1138566339
868458912
801627426
1029943737
1073658011
808184067
1167050015
1050309455
820130350
824112000
1079854870
1144534632
803373458
864328259
1038603957
1006193962
932107...

result:

ok 200000 numbers

Test #50:

score: 55
Accepted
time: 333ms
memory: 11284kb

input:

200000
0 1 2 3 5 13 14 16 20 24 26 27 29 31 35 37 44 51 56 58 59 62 70 72 73 82 83 87 90 91 93 97 100 102 105 107 111 113 115 116 118 120 128 135 138 140 143 146 148 150 156 158 160 162 164 172 174 176 177 179 181 189 195 196 199 204 205 211 214 216 218 220 222 223 224 226 229 233 235 238 244 246 24...

output:

800199994
1000000000
1072450094
992546790
1113838583
1105182127
866014034
1014384794
1147954849
1057923813
816560262
1045456151
1072871581
1129368323
1102871277
804387579
853939037
1087545074
1175621173
1158651938
1038932359
1195384033
1133615060
821428712
1071605248
1121900787
908716458
997325704
8...

result:

ok 200000 numbers

Test #51:

score: 55
Accepted
time: 330ms
memory: 11336kb

input:

200000
0 4 5 7 12 15 18 23 26 29 31 33 36 37 38 39 44 47 48 50 51 53 56 57 62 64 67 73 74 77 80 84 98 100 103 105 109 111 117 119 125 126 128 130 133 141 144 146 149 151 153 155 156 159 160 162 166 172 174 179 183 184 185 191 192 196 197 200 204 206 210 212 217 219 221 223 224 229 233 237 239 242 24...

output:

800199993
1000000000
871844795
890408767
1109438057
1130003493
1115999115
866446576
894004882
801200061
1071445400
884962253
1105902088
1171552915
959359805
814634169
855604943
1035272012
1067059238
1052266244
1058684442
1126501096
1155383994
941075493
1087579225
1064620016
1161285296
1028240361
858...

result:

ok 200000 numbers

Extra Test:

score: 0
Extra Test Passed