QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#82322 | #5405. 爬楼梯 | zhouhuanyi | 100 ✓ | 431ms | 96416kb | C++23 | 2.6kb | 2023-02-27 15:34:48 | 2023-02-27 15:34:49 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 200000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int n,m,rt[N+1],h[N+1],p[N+1],pst[N+1];
long long ans;
struct seg
{
struct node
{
int ls,rs,data;
long long data2;
};
node tree[20*N+1];
int length;
void push_up(int k)
{
tree[k].data=tree[tree[k].ls].data+tree[tree[k].rs].data,tree[k].data2=tree[tree[k].ls].data2+tree[tree[k].rs].data2;
return;
}
int add(int k,int L,int R,int x,int d)
{
int nw=++length;
tree[nw]=tree[k];
if (L==R)
{
tree[nw].data+=d,tree[nw].data2+=d*h[p[x]];
return nw;
}
int mid=(L+R)>>1;
if (x<=mid) tree[nw].ls=add(tree[nw].ls,L,mid,x,d);
else tree[nw].rs=add(tree[nw].rs,mid+1,R,x,d);
push_up(nw);
return nw;
}
int find(int p,int q,int L,int R,int x)
{
if (L==R) return L;
int mid=(L+R)>>1;
if (x<=tree[tree[q].ls].data-tree[tree[p].ls].data) return find(tree[p].ls,tree[q].ls,L,mid,x);
else return find(tree[p].rs,tree[q].rs,mid+1,R,x-(tree[tree[q].ls].data-tree[tree[p].ls].data));
}
long long query(int k,int L,int R,int l,int r)
{
if (l>r) return 0;
if (L==l&&R==r) return tree[k].data2;
int mid=(L+R)>>1;
if (r<=mid) return query(tree[k].ls,L,mid,l,r);
else if (l>=mid+1) return query(tree[k].rs,mid+1,R,l,r);
else return query(tree[k].ls,L,mid,l,mid)+query(tree[k].rs,mid+1,R,mid+1,r);
}
};
seg T;
bool cmp(int x,int y)
{
return h[x]<h[y];
}
int main()
{
int l,r,ps,ps2,ps3;
n=read(),m=read();
for (int i=1;i<=n;++i) h[i]=read(),p[i]=i;
sort(p+1,p+n+1,cmp);
for (int i=1;i<=n;++i) pst[p[i]]=i;
for (int i=1;i<=n;++i) rt[i]=T.add(rt[i-1],1,n,pst[i],1);
while (m--)
{
l=read(),r=read(),ans=0;
if (!((r-l+1)&1))
{
ps=T.find(rt[l-1],rt[r],1,n,(r-l+1)>>1),ps2=T.find(rt[l-1],rt[r],1,n,((r-l+1)>>1)+1);
ans-=((T.query(rt[r],1,n,1,ps-1)-T.query(rt[l-1],1,n,1,ps-1))<<1);
ans+=((T.query(rt[r],1,n,ps2+1,n)-T.query(rt[l-1],1,n,ps2+1,n))<<1);
printf("%lld\n",ans+h[p[ps2]]-h[p[ps]]);
}
else
{
ps=T.find(rt[l-1],rt[r],1,n,((r-l+1)>>1)),ps2=T.find(rt[l-1],rt[r],1,n,((r-l+1)>>1)+1),ps3=T.find(rt[l-1],rt[r],1,n,((r-l+1)>>1)+2);
ans-=((T.query(rt[r],1,n,1,ps-1)-T.query(rt[l-1],1,n,1,ps-1))<<1);
ans+=((T.query(rt[r],1,n,ps3+1,n)-T.query(rt[l-1],1,n,ps3+1,n))<<1);
printf("%lld\n",ans+h[p[ps3]]-h[p[ps]]+max(h[p[ps2]]-h[p[ps]],h[p[ps3]]-h[p[ps2]]));
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 5496kb
input:
10 10 323351358 540774025 513831404 171513818 162079008 234580967 887182642 765979034 329924749 677555871 2 4 1 6 8 10 2 5 1 9 4 6 9 10 2 10 1 8 8 10
output:
711577793 1530795597 783685407 1099707620 3625910517 135569108 347631122 3919843439 3442003862 783685407
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 3ms
memory: 5764kb
input:
10 10 356685563 915148434 563845435 480227923 510014130 571548808 489307692 666691543 573877683 800166552 5 8 1 4 1 10 3 10 1 7 3 8 5 8 5 6 5 6 2 4
output:
416302380 1200543254 2247001181 1130075439 1427936560 591240777 416302380 61534678 61534678 786223510
result:
ok 10 numbers
Test #3:
score: 0
Accepted
time: 2ms
memory: 5760kb
input:
10 10 259041296 18437783 835927251 200068667 931291913 220668768 841571584 64630364 869262858 448307535 5 10 4 9 4 9 3 10 8 10 4 6 2 5 2 4 1 4 3 8
output:
3423775327 3692614296 3692614296 4701136828 1225587817 1441846391 2461566844 1453348052 1693951565 3631587415
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 7572kb
input:
10 10 694546061 683750732 282826928 44704999 202358913 413195054 57606354 882383775 603016817 756343723 3 10 1 9 2 10 6 8 3 5 5 7 1 8 1 7 4 6 1 4
output:
4004516224 4422032256 4545627580 1293966142 395775843 566424841 4042388730 2893175147 579326196 1700605928
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 2ms
memory: 5604kb
input:
10 10 75522620 489110151 476088987 919220128 114109105 664499311 296664800 117714384 936389932 742669420 5 10 1 10 4 10 1 2 3 9 2 4 1 6 6 8 2 4 5 6
output:
3262306237 5330556928 4061412273 413587531 3803817977 873241118 2801196592 914619438 873241118 550390206
result:
ok 10 numbers
Test #6:
score: 0
Accepted
time: 2ms
memory: 7536kb
input:
10 10 708842660 535631736 313983181 60960887 709239973 805842351 640508065 995203777 786390356 570768327 5 7 7 9 7 10 7 9 2 8 6 8 4 10 8 10 5 6 3 5
output:
261936664 563509133 994753191 563509133 3130688686 544057138 2561666502 640057479 96602378 1043535878
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 5596kb
input:
10 10 949140873 817668912 216488537 181549618 394932991 526353574 808587752 448239013 817070969 296679334 6 10 2 8 2 7 1 8 6 10 3 6 5 8 2 3 4 10 2 7
output:
1683366187 2665972162 2587857601 3642967343 1683366187 868052366 905424083 601180375 2504394682 2587857601
result:
ok 10 numbers
Test #8:
score: 0
Accepted
time: 2ms
memory: 7660kb
input:
10 10 216976438 311196676 362414991 166779537 394400237 257402421 7949303 795846086 161382188 190830847 4 8 6 9 6 9 4 7 3 9 1 7 4 9 2 7 7 10 4 8
output:
1940412082 1671813799 1671813799 863524752 2342477688 1312187269 2132452548 1217967031 1605242225 1940412082
result:
ok 10 numbers
Test #9:
score: 0
Accepted
time: 2ms
memory: 5524kb
input:
10 10 168117094 215701804 648251116 480535594 268077263 814190009 150894926 29759319 963450984 384460880 6 8 1 7 2 8 2 9 1 3 3 4 3 8 6 8 4 10 2 4
output:
1447725773 2764150331 3040865881 4271530451 912683334 167715522 2776032091 1447725773 3522815444 697383102
result:
ok 10 numbers
Test #10:
score: 0
Accepted
time: 2ms
memory: 5768kb
input:
10 10 16571107 681078796 450724252 846525392 447473866 502898147 991995131 660439261 933193062 456232325 4 7 4 9 1 6 1 8 3 5 2 3 7 9 2 7 3 10 5 7
output:
1432669775 2135718491 2179292325 3367201302 794852666 230354544 604309671 2058825459 2992107398 1033618249
result:
ok 10 numbers
Subtask #2:
score: 10
Accepted
Test #11:
score: 10
Accepted
time: 304ms
memory: 95916kb
input:
200000 200000 1 2 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 1 1 1 2 2 2 1 1 2 2 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 1 2 2 1 1 2 1 1 1 2 1 1 2 1 2 1 1 1 2 1 2 2 2 2 1 2 2 1 1 2 2 1 2 2 1 1 1 1 2 2 2 1 1 1 1 1 2 2 1 1 1 1 2 1 2 1 2 2 2 2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 1 ...
output:
17766 92870 56732 16462 79590 3872 79674 3370 151158 52672 41424 27644 52872 33690 47896 76136 59296 75972 113274 89092 114330 48490 24112 6810 164898 10914 9738 3316 33638 1510 16344 10722 89260 87924 12710 11498 464 61810 9336 100798 59812 170450 7374 78296 10230 173826 56696 106278 7504 141524 52...
result:
ok 200000 numbers
Test #12:
score: 0
Accepted
time: 295ms
memory: 95008kb
input:
200000 200000 1 1 1 2 2 1 1 1 2 1 1 2 1 1 2 2 1 1 2 1 1 2 2 2 1 1 2 2 2 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 1 1 1 2 1 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 2 2 1 1 2 2 1 1 1 1 2 1 1 1 1 2 2 2 1 2 2 2 1 2 1 1 2 1 2 2 2 1 1 1 2 2 2 2 2 2 1 1 2 1 1 2 1 2 2 2 1 1 1 2 2 2 2 1 2 2 2 2 ...
output:
34634 186070 40474 51812 74324 113772 143412 32850 159512 144058 50840 48476 63358 109344 61042 23484 20510 107934 83810 4928 35586 4418 115660 93302 74510 27160 118828 23978 63160 94808 93788 139628 116770 122686 6838 86990 129516 95050 127920 24436 125294 34376 92218 48038 18018 18998 30662 22800 ...
result:
ok 200000 numbers
Test #13:
score: 0
Accepted
time: 302ms
memory: 95988kb
input:
200000 200000 1 1 1 1 2 2 2 1 2 2 2 1 1 2 2 1 1 1 2 1 2 1 2 2 2 1 2 2 2 1 2 1 1 2 2 1 1 1 2 1 2 2 2 2 1 1 2 2 2 1 1 1 2 2 1 2 1 1 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 1 1 1 1 2 1 1 1 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 1 1 2 1 1 2 1 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 2 2 ...
output:
30180 3450 11204 13074 148502 130972 80042 52894 87820 109242 78962 28404 53748 7980 105422 56700 183670 14292 119848 143010 123090 85064 38840 47242 36332 14212 1644 36980 80758 111014 96414 96446 38670 8604 43886 88204 18960 87890 50892 107186 21344 1246 68720 63862 8724 52470 113760 12034 79240 1...
result:
ok 200000 numbers
Test #14:
score: 0
Accepted
time: 285ms
memory: 94800kb
input:
200000 200000 2 1 2 2 2 2 1 2 1 1 2 2 1 1 2 2 1 1 2 2 1 2 2 1 2 1 2 1 1 1 2 1 2 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 2 1 2 2 1 2 2 1 2 1 2 1 1 1 2 1 2 2 2 2 1 1 2 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 1 2 1 2 2 1 1 1 2 1 1 1 1 2 1 1 1 2 2 1 2 1 1 1 2 2 1 1 2 2 2 2 1 1 1 2 2 ...
output:
13022 134246 119602 92008 13162 73656 135398 88386 126060 9520 20108 115532 122146 49014 43682 25498 139232 18854 57476 127406 7926 51236 15566 108124 2018 55108 155408 13502 129392 137254 113628 34892 121138 150788 102334 34000 15094 26870 8520 96532 51126 52014 22954 66196 71570 96094 48444 42750 ...
result:
ok 200000 numbers
Test #15:
score: 0
Accepted
time: 299ms
memory: 94664kb
input:
200000 200000 1 1 1 1 1 1 1 2 2 2 1 2 1 1 1 1 2 1 1 2 2 1 2 2 2 1 1 1 1 2 1 1 1 1 2 2 2 2 2 2 1 2 2 2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 1 2 2 2 2 1 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 1 2 2 1 2 1 2 1 2 2 2 2 1 2 1 2 1 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 2 2 1 2 2 2 2 1 1 1 1 1 1 2 1 2 2 2 2 1 1 1 1 2 2 2 1 1 1 2 1 ...
output:
48582 6872 24696 139252 76658 34278 35374 12294 122826 33 51450 149990 14150 79158 86212 146016 74428 52718 16548 169422 158372 96190 12256 24888 92880 87502 17934 61298 61614 65784 116924 33316 105728 31730 5162 6552 74088 10308 49304 48234 64130 48080 696 19114 81462 155474 101056 64116 32960 1650...
result:
ok 200000 numbers
Test #16:
score: 0
Accepted
time: 279ms
memory: 95140kb
input:
200000 200000 2 1 1 1 1 2 1 2 2 2 1 2 1 1 2 1 1 2 1 2 2 2 1 1 2 1 1 2 1 1 2 2 2 1 1 2 2 1 1 2 2 2 1 1 1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 1 2 1 2 2 1 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 1 1 1 2 1 2 2 2 2 1 2 2 2 1 1 1 2 1 1 1 2 2 2 1 2 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 1 2 2 2 2 1 2 2 1 2 1 2 2 2 1 1 1 2 2 1 ...
output:
121730 5206 27378 36224 80674 95732 7556 37212 52848 78086 126638 39604 71342 28294 95564 136746 102870 4370 47068 38292 111382 74502 79350 33848 24888 55198 33708 79214 129152 125074 28038 128414 126114 24838 20918 5234 20476 85442 43684 125780 116178 7372 24176 14296 104564 33300 31370 107766 4671...
result:
ok 200000 numbers
Test #17:
score: 0
Accepted
time: 291ms
memory: 95868kb
input:
200000 200000 2 2 2 1 2 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 2 2 2 1 1 2 2 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 2 2 1 2 2 1 2 2 1 1 1 2 1 1 1 2 2 2 2 1 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 1 2 1 2 2 2 1 2 1 2 2 2 2 2 2 1 2 2 1 1 2 2 1 1 2 2 1 2 2 2 2 2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 2 1 2 1 2 1 1 2 2 2 1 ...
output:
2208 102160 38506 104236 48716 141904 69076 94228 88968 14472 99250 85976 135724 41334 63612 61194 12336 72532 15200 182060 63002 91832 71954 67888 5262 33678 24420 27094 104114 146 328 150076 25408 64996 22704 95500 3398 89342 57594 3840 38392 73176 123976 36628 68980 88136 14884 30956 48840 85184 ...
result:
ok 200000 numbers
Test #18:
score: 0
Accepted
time: 265ms
memory: 94792kb
input:
200000 200000 2 1 2 1 1 2 2 1 2 1 2 2 2 1 2 1 2 1 1 1 1 1 2 1 1 2 2 1 1 1 2 2 2 2 1 2 1 2 1 1 2 1 1 2 1 1 2 2 1 1 2 2 2 2 1 1 2 1 1 1 1 1 2 2 2 2 1 1 2 1 1 1 2 2 2 2 1 2 1 1 1 1 2 1 1 2 1 2 1 2 2 1 1 2 1 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 2 1 2 1 1 1 2 1 1 1 2 2 2 2 1 2 2 1 2 1 2 1 2 1 1 1 2 1 1 1 1 1 1 ...
output:
40110 86054 7820 111738 7270 61898 35328 8392 25652 15106 90212 48114 40102 42102 93144 122112 5888 25884 19168 33284 25020 137562 66590 16468 7898 44420 33858 108998 17768 31096 9342 78576 40496 60600 107784 105508 39370 73000 151258 47718 61834 116814 88044 116160 55036 167796 135812 90236 69586 9...
result:
ok 200000 numbers
Test #19:
score: 0
Accepted
time: 294ms
memory: 96088kb
input:
200000 200000 2 2 1 2 1 2 2 2 1 1 2 1 1 1 1 1 2 1 2 2 1 1 2 1 2 2 2 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 1 1 2 1 2 1 1 1 2 1 1 1 2 2 1 2 1 1 1 1 1 1 2 2 2 1 1 1 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 1 2 1 1 2 2 1 2 2 2 1 2 2 1 2 2 2 2 1 1 1 2 2 1 1 2 1 1 2 1 1 2 2 1 2 2 2 1 1 2 1 1 1 1 1 2 2 2 2 2 2 2 ...
output:
162036 18978 42904 66578 155524 15368 54002 86214 94220 110102 88156 98612 2446 115006 99172 32232 62964 57398 114400 81306 35150 119398 71542 38160 43048 32222 60084 32398 22606 130652 154536 73254 29208 65734 49880 19994 26114 63156 17292 51504 16392 108188 173554 28578 60564 14456 74482 144720 49...
result:
ok 200000 numbers
Test #20:
score: 0
Accepted
time: 287ms
memory: 95188kb
input:
200000 200000 1 1 2 1 1 1 2 2 1 1 2 2 1 1 2 2 2 2 1 1 1 2 2 2 1 1 2 2 2 2 2 2 1 2 1 2 1 2 1 1 1 1 1 1 1 2 2 1 2 1 1 1 1 1 2 2 2 2 2 1 1 2 2 2 2 1 1 1 2 1 2 2 2 1 1 2 2 2 2 2 1 1 2 2 2 1 1 1 1 1 1 2 2 1 2 1 1 2 2 1 2 2 2 2 2 1 2 1 1 2 2 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 ...
output:
23836 30092 180998 59448 117750 56030 90790 36820 134968 97314 100600 70630 69220 86388 87458 36282 92862 36224 35728 52382 82620 85024 6276 73508 41444 61282 103070 141644 91920 16652 15544 70666 136362 37674 56476 20866 138534 120686 87134 81934 121702 94000 15266 153606 116372 114098 13844 113104...
result:
ok 200000 numbers
Subtask #3:
score: 20
Accepted
Dependency #2:
100%
Accepted
Test #21:
score: 20
Accepted
time: 374ms
memory: 95620kb
input:
200000 200000 2 2 1 3 3 1 1 3 1 2 3 1 1 2 1 2 2 3 3 1 2 3 1 3 1 1 2 1 3 1 2 1 3 2 3 2 3 2 2 3 2 3 1 1 1 2 3 2 1 1 1 2 2 2 1 1 3 2 3 1 2 1 2 2 3 1 3 2 2 1 2 3 1 2 2 1 1 2 1 1 2 2 1 2 2 2 3 1 1 3 2 3 1 2 2 1 2 3 1 2 3 2 3 3 1 2 1 1 1 1 2 1 1 2 1 3 2 1 2 3 1 1 2 2 2 3 2 2 2 1 2 1 2 2 3 3 3 2 2 3 1 3 1 ...
output:
67298 55468 159392 3114 154332 73750 83244 197408 3814 64544 45538 222396 73420 101340 121448 49368 122248 95026 5206 51198 53084 64706 74262 14474 3538 209226 26128 27000 80008 37380 32102 65130 4836 16024 104892 53806 66150 1910 60680 36392 169856 12842 68530 13216 50144 57006 91856 95944 21622 16...
result:
ok 200000 numbers
Test #22:
score: 0
Accepted
time: 366ms
memory: 94656kb
input:
200000 200000 3 2 3 1 2 2 1 2 2 1 2 1 1 2 3 3 3 2 2 2 1 1 1 1 3 1 3 1 2 1 3 3 1 2 1 2 2 1 3 3 1 1 3 3 2 2 2 3 2 3 2 3 2 2 2 3 2 3 2 3 3 1 2 2 2 1 1 1 3 3 3 1 1 1 3 2 3 2 3 1 3 3 2 1 3 1 1 2 1 1 1 1 1 1 3 3 3 1 1 2 3 2 2 2 3 2 2 2 1 1 3 1 2 2 1 2 3 2 1 3 3 2 2 1 3 1 2 1 3 3 3 2 3 1 3 1 1 1 1 1 1 1 3 ...
output:
96510 20926 88100 122354 47556 33760 77532 80496 230968 71308 95212 54908 61394 8446 13426 122666 122132 21696 112202 149080 95378 26840 102152 68774 141792 80 20226 49888 200168 98716 31614 33832 88488 58820 115252 169652 94036 103002 12056 147980 23134 89928 1470 9770 30404 21042 104390 53468 5654...
result:
ok 200000 numbers
Test #23:
score: 0
Accepted
time: 396ms
memory: 95544kb
input:
200000 200000 3 2 1 1 1 3 1 3 3 3 2 3 1 1 2 1 1 3 1 2 2 1 1 3 3 3 3 2 1 3 2 3 3 1 3 3 2 2 3 2 3 3 3 2 2 3 2 1 3 1 1 3 3 3 1 1 3 2 1 1 2 2 2 2 3 3 1 2 3 3 2 2 2 1 2 3 3 3 2 1 3 1 2 2 1 3 1 2 2 3 1 2 2 2 1 3 3 2 2 2 3 3 2 1 3 1 1 1 2 2 3 3 1 3 1 1 1 1 2 1 2 2 1 2 2 2 3 2 3 2 1 3 2 3 1 3 2 1 3 3 1 2 1 ...
output:
171594 146470 236994 200326 212962 7194 68950 18520 14600 13620 116044 72084 56114 104228 51830 1516 25534 15602 189066 16048 23108 51596 76734 181234 137732 94262 24430 125112 190438 800 64358 29476 182352 75488 99612 80936 201512 20962 80216 119254 34224 5744 8564 62404 64050 181832 47538 150016 6...
result:
ok 200000 numbers
Test #24:
score: 0
Accepted
time: 394ms
memory: 94484kb
input:
200000 200000 2 3 3 3 3 2 1 2 2 2 1 2 3 3 1 3 3 2 1 2 3 3 1 3 3 3 3 2 1 3 2 1 2 3 3 2 1 2 1 2 1 3 2 2 3 2 3 3 3 2 2 2 1 3 1 2 3 1 3 1 3 3 1 3 3 3 1 3 2 3 1 2 2 1 1 3 3 1 1 3 3 1 1 1 2 2 1 2 2 3 1 3 2 2 1 2 2 3 2 2 3 1 3 3 1 3 2 2 3 2 2 2 3 2 2 3 2 2 2 1 3 2 3 2 1 1 1 3 2 1 3 2 3 3 1 1 1 2 2 1 1 1 1 ...
output:
72512 182044 205170 105118 28506 140120 47606 39452 20546 60200 116888 42000 80466 85936 10634 54370 196698 114590 3618 60100 124790 18608 67732 158128 67796 85696 39476 214724 178318 54798 13798 218562 17564 86742 128110 117528 176722 50034 110678 31460 138210 81594 32268 65184 49414 45388 138386 1...
result:
ok 200000 numbers
Test #25:
score: 0
Accepted
time: 360ms
memory: 94748kb
input:
200000 200000 1 1 1 1 2 1 3 1 2 3 3 1 3 1 3 1 2 1 3 1 3 2 1 2 1 2 2 1 1 1 2 3 1 2 1 3 2 2 3 1 1 2 2 3 3 3 3 3 3 2 1 2 3 1 3 1 1 3 1 3 2 2 1 2 1 2 1 3 3 3 3 2 2 1 1 1 1 2 3 1 3 3 2 3 2 3 3 1 1 2 1 1 3 3 2 2 2 1 1 2 3 3 1 2 3 2 3 2 2 2 3 2 2 2 2 1 2 3 2 3 1 3 1 3 2 2 2 1 2 3 1 1 2 2 3 2 3 3 3 3 2 3 3 ...
output:
85308 106742 74528 87764 2010 116116 30234 23238 38198 63668 6592 55068 43044 103302 110830 96468 209954 42726 17058 72240 253218 139530 239070 110024 86796 168052 177056 74154 52140 65304 98942 127890 232752 125390 87598 35308 111272 25410 79640 119300 30542 191908 157956 53216 37486 122298 5848 57...
result:
ok 200000 numbers
Test #26:
score: 0
Accepted
time: 380ms
memory: 95744kb
input:
200000 200000 3 1 3 2 2 3 2 2 2 3 2 2 2 2 2 3 2 1 2 1 3 2 1 2 1 3 1 3 3 1 1 1 1 1 3 1 2 1 2 2 1 1 2 1 2 1 2 3 3 3 1 2 2 1 1 1 3 3 2 1 2 3 2 1 1 1 2 1 1 1 2 1 3 2 1 2 2 3 1 2 2 3 1 3 1 1 2 3 3 1 2 3 2 1 3 3 3 1 1 1 1 2 2 2 3 3 2 2 2 2 1 1 3 2 3 1 2 3 2 1 2 1 3 3 3 2 1 2 1 2 3 3 1 3 2 2 2 3 2 3 2 1 1 ...
output:
38754 138862 87876 125794 51796 16858 142694 8442 83138 115612 242666 130086 114500 430 63366 155974 34554 176628 215830 53386 15860 54338 2970 101306 51042 141616 66844 11538 108188 34368 102254 30116 38542 51100 4472 169224 98548 35404 91160 61708 94900 28030 62360 26110 41624 69940 22462 82116 95...
result:
ok 200000 numbers
Test #27:
score: 0
Accepted
time: 359ms
memory: 95948kb
input:
200000 200000 2 3 3 2 3 2 2 3 1 2 2 2 3 2 2 3 1 3 1 1 3 2 1 1 1 2 2 3 2 2 3 2 1 1 2 2 3 1 2 1 3 2 2 2 2 3 2 1 3 1 2 2 3 1 3 2 3 1 2 3 1 2 2 2 2 3 2 2 2 3 2 1 1 1 1 3 1 1 2 3 3 3 1 3 1 2 3 3 2 2 2 1 1 2 2 2 3 3 3 3 2 2 1 3 3 3 1 3 2 1 1 3 3 1 2 3 2 3 3 1 3 3 3 1 3 1 1 2 2 1 2 2 2 2 1 3 2 1 1 2 2 1 1 ...
output:
59586 53592 56242 71178 238432 71020 48096 151456 24016 160048 52490 59920 130336 106794 82034 64464 78834 17558 103034 11914 144760 17844 221012 14580 245400 32192 143684 176780 9862 87072 97030 7054 107142 69214 59314 62538 83608 212090 155600 130128 45762 86934 32068 177140 130902 64480 111442 41...
result:
ok 200000 numbers
Test #28:
score: 0
Accepted
time: 391ms
memory: 94852kb
input:
200000 200000 2 3 1 3 3 3 3 1 2 2 2 1 3 1 2 2 2 1 1 2 2 2 1 3 3 3 1 3 1 3 1 3 2 3 2 1 3 2 3 1 2 3 3 2 3 3 2 3 2 3 3 3 3 1 2 3 1 2 1 3 1 2 2 3 1 3 3 1 3 3 1 2 3 3 3 3 1 2 3 1 3 2 1 2 3 1 1 3 1 1 3 2 3 3 2 2 2 3 1 1 1 2 1 3 2 1 1 3 3 2 3 2 2 2 3 1 3 3 3 1 2 1 3 2 3 3 3 1 3 3 1 2 2 1 3 2 3 1 1 2 1 1 2 ...
output:
88592 22422 120918 57926 22442 50646 25028 167560 42058 139420 93808 54530 77048 61572 159256 22542 72102 114708 51570 50042 7322 84838 26128 106694 25810 7738 38036 24270 4580 40870 98156 31522 802 12340 30020 55614 140986 27002 69396 158768 99050 91982 44146 173866 99586 95290 9566 502 37206 44510...
result:
ok 200000 numbers
Test #29:
score: 0
Accepted
time: 358ms
memory: 95828kb
input:
200000 200000 2 1 3 2 2 2 2 2 3 2 3 3 1 2 2 3 2 1 3 3 1 3 1 3 1 3 3 1 2 3 2 1 3 2 3 2 3 1 2 3 1 2 3 3 2 1 3 2 2 1 2 2 3 2 3 1 3 1 1 1 1 3 3 3 1 2 2 2 1 3 3 1 2 3 1 2 1 2 1 2 3 2 3 3 3 2 3 2 2 1 3 3 2 2 3 2 3 1 1 2 2 3 1 1 2 1 2 2 3 1 3 3 3 1 3 1 2 2 1 3 3 2 1 2 2 2 3 2 3 3 3 1 3 2 2 2 3 1 1 1 3 1 1 ...
output:
35380 134980 88136 136290 52684 82300 59860 65386 78984 81808 15690 87784 29068 33428 22120 118440 163628 2600 139222 177788 97614 46038 194390 1356 154656 179672 23584 60418 117210 65226 116928 181784 148104 46758 167936 17046 5774 107240 7070 154168 199248 75902 58760 123480 111204 158612 96002 37...
result:
ok 200000 numbers
Test #30:
score: 0
Accepted
time: 394ms
memory: 95084kb
input:
200000 200000 3 2 3 2 1 3 1 2 1 2 2 1 2 3 1 1 3 3 1 2 3 1 3 2 3 3 3 3 2 2 1 1 2 3 1 1 2 1 3 1 1 2 3 3 1 3 1 1 3 3 3 2 2 2 3 2 1 3 1 2 3 3 1 3 1 1 2 3 1 2 2 1 2 1 1 2 3 1 1 2 1 2 1 2 2 3 2 2 3 2 2 2 2 2 1 3 2 2 3 2 3 1 1 2 1 3 3 2 1 1 2 2 3 2 1 2 1 3 3 2 1 1 2 2 2 1 3 1 2 2 1 3 1 2 2 1 1 1 2 2 2 1 2 ...
output:
41500 73202 79350 184062 142674 8922 72642 208954 10728 193668 26812 37150 108884 110726 12450 142314 224498 163978 80106 2552 67388 59730 96712 210282 90284 125408 153406 134242 51634 59584 102174 47450 79554 157816 46212 160464 63256 54804 149594 42306 56482 166510 151788 47870 186388 121478 36834...
result:
ok 200000 numbers
Subtask #4:
score: 25
Accepted
Dependency #1:
100%
Accepted
Test #31:
score: 25
Accepted
time: 5ms
memory: 6304kb
input:
2000 2000 934094958 536783701 145230662 389097466 662916743 15680595 497269445 277327696 295204335 399565879 103085285 660476806 406097164 491009942 123591789 940451006 657478375 690285007 370217804 34759017 896304691 785120106 102507838 814135240 179075942 374826926 706283825 750182730 494056277 17...
output:
273757423642 66476977112 237905924503 268145773779 1009274567874 133235037708 490463511544 488261294368 281356752080 752867613163 140878891959 116280565475 431247126230 47187175834 623046882965 168840754351 84041149197 380784864121 163937321134 258535804412 446360806108 98427472953 348024159178 9069...
result:
ok 2000 numbers
Test #32:
score: 0
Accepted
time: 1ms
memory: 6344kb
input:
2000 2000 430676823 601313211 831915691 571317219 725924558 359178143 624054422 334329457 97735569 856155674 622583253 647480072 233495215 952504395 933848132 946405571 119999572 531138207 563350953 468019888 525396948 259152810 547609710 173524832 37300825 977998768 298207574 937208131 54221721 646...
output:
572256829943 664805649055 156946619190 609964613731 133184514146 27573811698 176175454437 480273237819 15693149570 496044812586 339601590747 60339154451 402831452507 396565742189 145255610947 684304273826 529869367988 569576214542 364096388216 239357736074 76777255979 141189744624 104700932792 29812...
result:
ok 2000 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 8196kb
input:
2000 2000 174014840 454415074 704208482 737283911 176268494 955596481 780620368 922940830 113662017 357753017 180602769 884541098 995110533 972424845 416643161 17062213 59822798 882594371 179243682 831650483 518716292 444497323 11781122 374065322 88742263 810718669 323090508 515110143 884032936 9006...
output:
22816186265 77800170465 109794318366 761973373672 667874385722 58937127966 673298255202 656249241920 373037668739 259563617900 892391641970 700898503534 589031039697 404791205133 463770946434 341922338103 325308823975 372238431670 86960098391 131814497048 422475685926 168082709910 428731393681 20723...
result:
ok 2000 numbers
Test #34:
score: 0
Accepted
time: 2ms
memory: 9804kb
input:
2000 2000 766609373 691046189 418705023 140123391 241375284 728021370 306085912 960170889 751838082 60655025 321302475 664067546 65554601 738423524 688635939 367516811 151877071 698520791 266626686 9006258 985650154 436540781 195639925 303307967 756113825 493299175 423713836 514385263 129004034 6837...
output:
106398326007 444075111660 610789371553 41911178095 24368907326 589488250310 80760460010 73516225638 343138692052 608480252486 476374324497 147551648827 442304902889 480904439360 130609437487 523685232322 580578038221 936135819125 72980481206 298704673171 477890373591 873940554658 503392518601 328989...
result:
ok 2000 numbers
Test #35:
score: 0
Accepted
time: 5ms
memory: 8216kb
input:
2000 2000 891212336 408279194 565848724 135604011 129057392 879469233 618947043 569874482 735901400 183512627 587549837 572418048 367287101 196841752 624574109 464852804 675146995 338288381 433459574 555739681 984676194 115127560 953477351 254225509 418033665 994658443 331668454 241149416 892832595 ...
output:
547212804074 205771194015 333486581416 434141914457 341756217613 934556963115 453685752318 84922309760 940269005494 79033995712 495995780125 520016250954 8338652820 377605691349 48690451855 188223693504 749357214275 119206104803 228193087627 90751428033 717129505812 389354510408 593894845532 2342478...
result:
ok 2000 numbers
Test #36:
score: 0
Accepted
time: 1ms
memory: 6184kb
input:
2000 2000 807173723 997155885 419270522 935663725 907994153 434775316 156728805 573582873 964218336 897693638 148147286 734808404 245768500 440875090 961107912 397790456 923739660 156116150 98166935 461713740 437022167 104127972 639348136 853089968 538366721 694838933 485242447 167523330 939186585 4...
output:
766500559759 589679140895 150395877755 294329889604 628195695376 763776164556 396441632021 598437520894 721697370214 459397382254 232016405279 192206885310 12390529166 200873400822 156230263624 98275717561 693936500127 775027204810 84021105735 378266972679 541370083633 53345910650 11219676574 493004...
result:
ok 2000 numbers
Test #37:
score: 0
Accepted
time: 2ms
memory: 9652kb
input:
2000 2000 212521417 416574237 667588402 217263253 502694864 581047826 810159131 346030081 219031053 650358129 123544346 212980054 346630860 457301237 112931799 606517539 580390206 395607976 613186973 656120493 739930034 88705499 247560283 458317943 847419785 619362238 668913313 260719532 289431813 3...
output:
869009866222 796058030613 64004875968 365293671378 60668901837 769217825564 445399028935 150680900802 227157679155 64360178976 684185381404 259795137084 24454606503 215970172749 489063128868 52885676013 20554646079 882995288068 139119139694 24746656174 56976500940 691474317781 239170796505 756632924...
result:
ok 2000 numbers
Test #38:
score: 0
Accepted
time: 2ms
memory: 9808kb
input:
2000 2000 35890882 369605847 542056569 733407418 766672248 702007708 419920548 398879589 213854913 261894358 660194346 881124299 89901351 815239530 7033246 807633975 831205005 417554234 343541199 608284341 232793609 645022663 559597142 692586538 399928037 516620215 70284078 636526089 504735622 45073...
output:
234203498884 139403781378 59562729525 189131040262 28024577361 195340144124 71856217740 94600179097 281912519958 78097281573 158210947052 431655926756 436044750585 41699019036 572226747299 448929316840 171485631710 111606450461 140447490917 231694333428 160890552094 769720224560 611945982923 3018842...
result:
ok 2000 numbers
Test #39:
score: 0
Accepted
time: 4ms
memory: 6148kb
input:
2000 2000 661636400 560219770 459852949 229482128 598250483 161359788 157130457 76363928 392208323 34688283 65011889 327323787 854705792 599019820 956874290 528133115 568844284 979809792 380146932 989300539 574469058 976646053 175311403 474639310 445163210 558584734 679509015 752572539 732008023 721...
output:
248462475059 174715390624 587369878396 5864038656 111333836015 49060905026 415137874308 173786404310 385888151016 496816965736 32999135684 206478270702 368113626789 130208615270 514024725167 415817425650 80374038324 866370407850 292955076865 2451535467 548466582810 196620999192 725117557446 40359852...
result:
ok 2000 numbers
Test #40:
score: 0
Accepted
time: 4ms
memory: 6060kb
input:
2000 2000 907009150 50129623 814443705 62106767 631607632 803424557 509731948 710164263 254258872 514439222 781110806 661572333 114098981 670314213 202904104 891214898 268225132 356070882 800062334 221228736 149930659 955020793 266015184 131281825 246184627 487225990 107797484 935897116 451851837 78...
output:
307478406032 255977764737 397469624329 385813704241 672865530526 201844574227 53406749795 973978750658 580484394389 560269334368 229769045476 245695439336 918960950802 95002325100 76997236633 662075309473 26517974129 229329279683 214700364039 391295317323 435771899531 247697826258 565758183610 67039...
result:
ok 2000 numbers
Subtask #5:
score: 40
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #41:
score: 40
Accepted
time: 324ms
memory: 95408kb
input:
200000 200000 4 1 1 9 7 2 3 5 2 4 6 3 7 4 6 10 2 5 6 10 5 3 10 9 7 1 2 1 5 3 8 1 6 3 2 9 4 10 4 10 2 4 6 3 4 10 2 5 6 8 8 7 1 9 9 3 10 6 6 5 10 10 7 7 8 1 6 3 4 5 8 4 5 2 3 3 9 2 4 2 5 5 2 4 4 9 7 10 8 9 9 4 2 8 4 8 1 10 4 8 9 6 7 9 7 9 6 6 1 10 9 9 8 6 8 7 5 9 6 10 6 8 10 10 7 6 5 2 5 5 3 3 4 4 3 3...
output:
12726 470966 420970 167606 829658 243802 89548 689218 189304 341290 319662 62714 109688 908438 204774 29010 514940 200526 478588 492384 768182 332898 763326 277092 158598 491392 717446 230768 175752 106686 725988 295914 122290 25228 478174 641014 126662 16678 116250 78620 413728 591166 67920 98722 9...
result:
ok 200000 numbers
Test #42:
score: 0
Accepted
time: 408ms
memory: 95068kb
input:
200000 200000 672940650 934751395 559651338 509343342 276110268 947498483 171786899 328099687 269271025 629560951 134105687 208668777 87580232 54393759 900763893 437079212 276223172 252353894 664438192 223307677 563179647 369460323 703144083 483233636 945622599 302608563 239479471 832089426 22567123...
output:
43596408210263 1713021334754 47875446353518 92500608782688 41076610069505 31727870608356 29428825391149 32273524551149 38089970727872 64857264579627 22102186094178 37597242817683 41708526359522 60393066149742 9159790285676 49876959094040 41587995103267 60096806284063 58551179532643 27682859273557 59...
result:
ok 200000 numbers
Test #43:
score: 0
Accepted
time: 397ms
memory: 95368kb
input:
200000 200000 649528382 206174718 650066749 124647255 359937766 430496754 519633712 766953850 283145263 695120420 576296576 176863270 726390455 674774285 828992652 121503228 826371725 141469413 4683966 684216174 341586831 873402423 65308919 296729652 361901615 619589120 235537943 440123195 282235423...
output:
44188590860539 55038927866885 13376722088042 5288802785011 68256953754161 34677390016345 71873627969538 43231591388694 20819705801006 35513975025250 50315601581038 7395720055541 54902682489082 5540902409095 37438137249029 28513407653741 36641224736870 35839711620242 27494728444216 33214693343663 286...
result:
ok 200000 numbers
Test #44:
score: 0
Accepted
time: 405ms
memory: 94704kb
input:
200000 200000 138335202 466075649 181229219 832966173 224321531 840170193 947912660 277803657 803410505 828139975 91175397 150523315 115482594 615816629 189960915 955211957 133855947 448847284 656121445 530992233 788490476 5877060 387603003 719563492 707116466 59343383 370091166 518548649 506395233 ...
output:
3873638705923 54551598188455 55027238059727 12238140740734 12050447287251 8566701249896 12023811022033 41540126929245 44679124733127 4256235680026 43035317839030 17543407522102 62574767581341 68559179790324 27583962032313 8523177324773 65770235612406 26452425076543 22593801990709 58083448292791 6555...
result:
ok 200000 numbers
Test #45:
score: 0
Accepted
time: 407ms
memory: 95916kb
input:
200000 200000 255664208 331404310 392156748 438022956 214485182 155511127 364558649 890507293 741768126 378228904 727737343 610015852 115292625 284303078 276953872 269082739 38757705 753309123 745671469 741065467 419118530 704384385 157358538 782069249 15638092 791834040 370299635 218663723 59870218...
output:
39995220806533 59490083833892 40037543087909 29964377890455 13687608919897 75368754776366 23333579420880 10403574438302 27540619700713 4608407497315 47841323353803 65084861524633 8741158009336 41252820014943 62644520234736 86305169377380 71844450843473 46458618122792 13012190552441 2108105162274 653...
result:
ok 200000 numbers
Test #46:
score: 0
Accepted
time: 421ms
memory: 94816kb
input:
200000 200000 794877427 318140430 172452677 221927878 814872167 566383488 444898926 121820389 453657442 668802596 717979354 862148602 327734727 810614072 407300449 174729448 833783881 643525317 725009621 408516281 87553842 410957493 68918557 277691159 665333568 927817282 452668940 924694345 70769273...
output:
24394755218410 21096494310893 78696707060020 12704941125052 53344432943250 35491841879040 8617507052473 38000164923549 5860660058047 22029565568472 64732623122525 414190852434 64053619073734 11216897921855 11506647077278 64862792960981 21204360142841 13302555213056 7249997152793 90852127913169 51615...
result:
ok 200000 numbers
Test #47:
score: 0
Accepted
time: 394ms
memory: 94880kb
input:
200000 200000 174878672 43947494 806891582 894511861 936818256 127382305 647534373 608325954 729755489 370411808 5981733 688645940 571943643 137518636 203205412 983693419 80370658 505703610 14354993 102350644 393976901 598363360 690011029 733669745 956403275 284884797 395706374 520054345 588919281 9...
output:
35402358703473 47208352864492 56230823006688 22249039864939 78681776927995 57373885178559 14464800058791 47790099336888 82993572078768 3947047365854 63923589017943 34388363783661 44325825899160 8971033876384 4390795733800 74156757384331 6866237468315 25235282062955 8550730362250 43192256386871 14604...
result:
ok 200000 numbers
Test #48:
score: 0
Accepted
time: 381ms
memory: 96416kb
input:
200000 200000 885702258 762756716 531109214 285956420 10552614 955892470 57506711 575707413 343396746 670472436 102030495 253647294 352054457 759735322 682512400 473919499 3127124 803848169 268705687 992763806 248916409 184933609 101104934 170686806 921933571 198719874 254509478 988472935 948849131 ...
output:
95471218226604 26135725143158 11842696501929 11494921175209 23774650709275 56281985640438 22102129592486 16334761807315 40297662960347 25275804938582 7727823768424 36938705015098 40341458195175 12240496078798 41572667706285 10751940875784 48834501979577 70254734870541 7690392118307 26173815514321 65...
result:
ok 200000 numbers
Test #49:
score: 0
Accepted
time: 412ms
memory: 94784kb
input:
200000 200000 762292552 80903976 12264125 897906911 506654286 562833720 661262006 929403490 165148739 311612984 384193023 629710520 344059900 147049032 154499459 972862462 749864593 902799801 982662261 334234118 885906176 377294710 511997551 243558008 82385543 247035498 768589410 521379288 441233095...
output:
12652870556321 34409838473007 6216538856444 10983447748310 41828499926656 27223393093933 29153135442718 9691353608546 49732563121753 71509778059569 51086063617811 69839647065831 1352273802355 60607375989262 18526839100703 43821470638024 4374845938114 30351729234756 42542580715893 18805005619007 1706...
result:
ok 200000 numbers
Test #50:
score: 0
Accepted
time: 431ms
memory: 95360kb
input:
200000 200000 216637621 346253004 122988718 602296533 977249595 380009989 830676113 707211540 856657652 732488697 250539820 282350892 810957011 679183177 814934539 448239599 66821534 865265003 489703321 210371239 216761966 938996829 829720354 162449392 192465885 996766190 730780993 346383233 6996923...
output:
26400551768003 9773723642202 79401843092766 81445569458593 32348487755998 60808786524698 29104129016576 375843048641 9419035959437 13174533123443 72983505582741 15987594477841 54972904217661 3804113115521 7675233587045 64256675273939 31470497740457 17544881148679 14931121004103 56940897448091 808442...
result:
ok 200000 numbers