QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#731681 | #9604. Cyberangel | lotus_f | 35 | 1987ms | 368152kb | C++14 | 9.6kb | 2024-11-10 10:27:33 | 2024-11-10 10:27:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace io
{
const int size = (1 << 20) + 1;
char buf[size], *p1 = buf, *p2 = buf;
char buffer[size];
int op1 = -1;
const int op2 = size - 1;
struct FastIO
{
inline char readchar()
{
return p1 != p2 ? *p1++ : p1 == (p2 = (p1 = buf) + fread(buf, 1, size - 1, stdin)) ? EOF
: *p1++;
}
// #ifndef ONLINE_JUDGE
// #define readchar getchar
// #endif
inline char rc()
{
char c=readchar();
while(c<32 || c==127) c=readchar();
return c;
}
inline void flush()
{
fwrite(buffer, 1, op1 + 1, stdout), op1 = -1;
}
inline void writechar(const char &x)
{
if (op1 == op2)
flush();
buffer[++op1] = x;
}
inline int readint()
{
int s = 1, x = 0;
char c = readchar();
while (c <= 32)
{
c = readchar();
}
if (c == '-')
{
s = -1, c = readchar();
}
while ('0' <= c && c <= '9')
{
x = x * 10 + c - '0';
c = readchar();
}
return x * s;
}
inline int readuint()
{
int x = 0;
char c = readchar();
while (c <= 32)
{
c = readchar();
}
while ('0' <= c && c <= '9')
{
x = x * 10 + c - '0';
c = readchar();
}
return x;
}
inline void writeint(int x)
{
if (x < 0)
{
writechar('-'), x = -x;
}
char s[24];
int n = 0;
while (x || !n)
{
s[n++] = '0' + x % 10, x /= 10;
}
while (n--)
{
writechar(s[n]);
}
}
inline void writeuint(unsigned x)
{
char s[24];
int n = 0;
while (x || !n)
{
s[n++] = '0' + x % 10, x /= 10;
}
while (n--)
{
writechar(s[n]);
}
}
inline long long readlonglong()
{
long long x = 0, s = 1;
char c = readchar();
while (c <= 32)
{
c = readchar();
}
if (c == '-')
{
s = -1, c = readchar();
}
while ('0' <= c && c <= '9')
{
x = x * 10 + c - '0';
c = readchar();
}
return x * s;
}
inline unsigned long long readulonglong()
{
unsigned long long x = 0;
char c = readchar();
while (c <= 32)
{
c = readchar();
}
while ('0' <= c && c <= '9')
{
x = x * 10 + c - '0';
c = readchar();
}
return x;
}
inline void writelonglong(long long x)
{
if (x < 0)
{
writechar('-'), x = -x;
}
char s[25];
int n = 0;
while (x || !n)
{
s[n++] = '0' + x % 10, x /= 10;
}
while (n--)
{
writechar(s[n]);
}
}
inline void writeulonglong(unsigned long long x)
{
char s[25];
int n = 0;
while (x || !n)
{
s[n++] = '0' + x % 10, x /= 10;
}
while (n--)
{
writechar(s[n]);
}
}
inline int readstring(char *s)
{
int cnt = 0;
char c = readchar();
while (c <= 32)
{
c = readchar();
}
while (c > 32)
{
*s++ = c, ++cnt;
c = readchar();
}
return *s = 0, cnt;
}
inline void writestring(const char *s)
{
while (*s)
{
writechar(*s++);
}
}
inline double readdouble()
{
int zheng = 0, fuhao = 1;
double xiao = 0, chushu = 10;
char c;
while ((c = readchar()) < '0' || c > '9')
{
if (c == '-')
{
fuhao = -1;
}
}
while (c >= '0' && c <= '9')
{
zheng = zheng * 10 + c - '0';
c = readchar();
}
if (c != '.')
{
return fuhao * zheng;
}
while ((c = readchar()) >= '0' && c <= '9')
{
xiao += (c - '0') / chushu;
chushu *= 10;
}
return fuhao * (zheng + xiao);
}
} io;
#define readc io::io.rc
#define writec io::io.writechar
#define read io::io.readint
#define readu io::io.readuint
// #define write io::io.writeint
#define writeu io::io.writeuint
#define readl io::io.readlonglong
#define readlu io::io.readulonglong
#define writel io::io.writelonglong
#define writelu io::io.writeulonglong
#define reads io::io.readstring
#define writes io::io.writestring
#define readd io::io.readdouble
#define flush io::io.flush
} using namespace io;
int n,m;
int a[1000010];
int tot=0,lsh[1000010];
vector<int> vec[1000010];
void write(__int128 x)
{
if(x==0) return putchar('0'),void();
int tot=0,dig[40];
while(x!=0) dig[++tot]=x%10,x/=10;
for(int i=tot; i>=1; --i) putchar(dig[i]+'0');
}
struct Tree
{
int firl,secl,firr,secr; // 最小的 l,最大的 r
__int128 suma,sumla,sumra,sumlra;
__int128 lsum1,lsum2;
__int128 rsum1,rsum2;
__int128 sum;
} tree[(1<<21)+10];
inline void push_up(int now)
{
if(tree[now<<1].firl<tree[now<<1|1].firl)
{
tree[now].firl=tree[now<<1].firl,tree[now].secl=min(tree[now<<1].secl,tree[now<<1|1].firl);
tree[now].sumra=tree[now<<1].sumra;
tree[now].lsum2=tree[now<<1].lsum2;
}
else if(tree[now<<1].firl==tree[now<<1|1].firl)
{
tree[now].firl=tree[now<<1].firl,tree[now].secl=min(tree[now<<1].secl,tree[now<<1|1].secl);
tree[now].sumra=tree[now<<1].sumra+tree[now<<1|1].sumra;
tree[now].lsum2=tree[now<<1].lsum2+tree[now<<1|1].lsum2;
}
else
{
tree[now].firl=tree[now<<1|1].firl,tree[now].secl=min(tree[now<<1].firl,tree[now<<1|1].secl);
tree[now].sumra=tree[now<<1|1].sumra;
tree[now].lsum2=tree[now<<1|1].lsum2;
}
if(tree[now<<1].firr>tree[now<<1|1].firr)
{
tree[now].firr=tree[now<<1].firr,tree[now].secr=max(tree[now<<1].secr,tree[now<<1|1].firr);
tree[now].sumla=tree[now<<1].sumla;
tree[now].rsum2=tree[now<<1].rsum2;
}
else if(tree[now<<1].firr==tree[now<<1|1].firr)
{
tree[now].firr=tree[now<<1].firr,tree[now].secr=max(tree[now<<1].secr,tree[now<<1|1].secr);
tree[now].sumla=tree[now<<1].sumla+tree[now<<1|1].sumla;
tree[now].rsum2=tree[now<<1].rsum2+tree[now<<1|1].rsum2;
}
else
{
tree[now].firr=tree[now<<1|1].firr,tree[now].secr=max(tree[now<<1].firr,tree[now<<1|1].secr);
tree[now].sumla=tree[now<<1|1].sumla;
tree[now].rsum2=tree[now<<1|1].rsum2;
}
tree[now].suma=0;
if(tree[now<<1].firl<=tree[now<<1|1].firl && tree[now<<1].firr>=tree[now<<1|1].firr)
{
tree[now].suma+=tree[now<<1].suma;
}
if(tree[now<<1|1].firl<=tree[now<<1].firl && tree[now<<1|1].firr>=tree[now<<1].firr)
{
tree[now].suma+=tree[now<<1|1].suma;
}
tree[now].sumlra=tree[now<<1].sumlra+tree[now<<1|1].sumlra;
tree[now].lsum1=tree[now<<1].lsum1+tree[now<<1|1].lsum1;
tree[now].rsum1=tree[now<<1].rsum1+tree[now<<1|1].rsum1;
tree[now].sum=tree[now<<1].sum+tree[now<<1|1].sum;
}
inline void upd_l(int now,int l)
{
tree[now].sumlra+=(l-tree[now].firl)*tree[now].sumra;
tree[now].sumla+=(l-tree[now].firl)*tree[now].suma;
tree[now].lsum1+=(l-tree[now].firl)*tree[now].lsum2;
tree[now].firl=l;
}
inline void upd_r(int now,int r)
{
tree[now].sumlra-=(tree[now].firr-r)*tree[now].sumla;
tree[now].sumra-=(tree[now].firr-r)*tree[now].suma;
tree[now].rsum1-=(tree[now].firr-r)*tree[now].rsum2;
tree[now].firr=r;
}
inline void push_down(int now)
{
int inl=min(tree[now<<1].firl,tree[now<<1|1].firl),axr=max(tree[now<<1].firr,tree[now<<1|1].firr);
if(inl!=tree[now].firl)
{
if(tree[now<<1].firl==inl) upd_l(now<<1,tree[now].firl);
if(tree[now<<1|1].firl==inl) upd_l(now<<1|1,tree[now].firl);
}
if(axr!=tree[now].firr)
{
if(tree[now<<1].firr==axr) upd_r(now<<1,tree[now].firr);
if(tree[now<<1|1].firr==axr) upd_r(now<<1|1,tree[now].firr);
}
}
bool upd_max(int now,int l,int r,int ql,int qr,int qz)
{
if(tree[now].firl>=qz) return 0;
if(ql<=l && r<=qr && tree[now].secl>qz) return upd_l(now,qz),1;
int mid=l+r>>1; bool change=0; push_down(now);
if(ql<=mid) change|=upd_max(now<<1,l,mid,ql,qr,qz);
if(qr>mid) change|=upd_max(now<<1|1,mid+1,r,ql,qr,qz);
if(change) push_up(now);
return change;
}
bool upd_min(int now,int l,int r,int ql,int qr,int qz)
{
if(tree[now].firr<=qz) return 0;
if(ql<=l && r<=qr && tree[now].secr<qz) return upd_r(now,qz),1;
int mid=l+r>>1; bool change=0; push_down(now);
if(ql<=mid) change|=upd_min(now<<1,l,mid,ql,qr,qz);
if(qr>mid) change|=upd_min(now<<1|1,mid+1,r,ql,qr,qz);
if(change) push_up(now);
return change;
}
void upd(int now,int l,int r,int qx,__int128 qa,int ql,int qr)
{
if(l==r) return tree[now]={ql,(int)1e9,qr,0,-qa,-qa*ql,-qa*qr,-qa*ql*qr,
qa*(qx-1)*ql,qa*(qx-1),qa*(qx+1)*qr,qa*(qx+1),-qa*(qx+1)*(qx-1)},void();
int mid=l+r>>1; push_down(now);
if(qx<=mid) upd(now<<1,l,mid,qx,qa,ql,qr);
else upd(now<<1|1,mid+1,r,qx,qa,ql,qr);
push_up(now);
}
void build(int now,int l,int r)
{
if(l==r)
{
__int128 a=lsh[tot];
tree[now]={1,(int)1e9,l,0,-a,-a,-a*l,-a*l,a*(l-1),a*(l-1),a*(l+1)*l,a*(l+1),-a*(l+1)*(l-1)};
return;
}
int mid=l+r>>1;
build(now<<1,l,mid),build(now<<1|1,mid+1,r);
push_up(now);
}
signed main()
{
n=read(),m=read();
lsh[++tot]=m+1;
for(int i=1; i<=n; ++i) a[i]=read(),lsh[++tot]=a[i];
sort(lsh+1,lsh+tot+1),tot=unique(lsh+1,lsh+tot+1)-lsh-1;
for(int i=1; i<=n; ++i) vec[lower_bound(lsh+1,lsh+tot+1,a[i])-lsh].push_back(i);
build(1,1,n);
__int128 ans=0;
for(int i=tot; i>=1; --i)
{
__int128 sum1=tree[1].sumlra+tree[1].lsum1+tree[1].rsum1+tree[1].sum;
for(int j:vec[i])
{
if(j!=1) upd_min(1,1,n,1,j-1,j-1);
if(j!=n) upd_max(1,1,n,j+1,n,j+1);
}
__int128 sum2=0;
for(int j=0; j<vec[i].size(); ++j)
{
int wz=vec[i][j];
int l=1,r=(j==vec[i].size()-1?n:vec[i][j+1]-1);
upd(1,1,n,wz,lsh[i],l,r);
sum2-=(__int128)lsh[i]*(wz-l+1)*(r-wz+1);
}
sum2+=tree[1].sumlra+tree[1].lsum1+tree[1].rsum1+tree[1].sum;
long long cnt=1ll*(n+1)*n/2; int lst=0;
for(int j:vec[i]) cnt-=1ll*(j-lst)*(j-lst-1)/2,lst=j;
cnt-=1ll*(n-lst+1)*(n-lst)/2;
ans+=lsh[i]*(sum1-sum2-(__int128)cnt*lsh[i]);
}
write(ans);
return 0;
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 32492kb
input:
500 995106803 150608560 532482040 23208958 442246216 2917205 948292264 962672628 610596054 69010421 206923685 605381259 560683057 374135360 323257595 224120348 773540778 414928542 327812091 524797091 241525558 228068400 618957683 365266079 992727350 87923118 536412424 557677355 392087162 158151043 2...
output:
59854856571283884484109
result:
ok single line: '59854856571283884484109'
Test #2:
score: 5
Accepted
time: 10ms
memory: 32488kb
input:
500 998177916 831776477 192175032 961088945 183712798 579677277 717304183 832903374 615887036 442602679 409553238 129885355 100943200 343489036 687786479 430405465 777511373 204923633 343819665 25948944 842220326 549608142 468749656 142098334 933571884 251697899 59109537 789796162 785935340 73343227...
output:
60246542713395218641133
result:
ok single line: '60246542713395218641133'
Test #3:
score: 5
Accepted
time: 0ms
memory: 30388kb
input:
500 997709021 801389775 126836923 995423900 219539434 339502026 400019091 497938039 72089859 869274947 184571531 95809171 59962362 417254404 298805403 917564456 174720088 556735156 56414432 280677373 588219772 522819920 10779045 716982277 910938390 725089141 281874084 483114735 734955935 987450129 1...
output:
60181661281845334448315
result:
ok single line: '60181661281845334448315'
Test #4:
score: 5
Accepted
time: 3ms
memory: 34448kb
input:
500 999864497 627827881 25595645 328673824 270847919 489497074 903403290 421254283 159758901 6189614 343812596 911516439 60128926 482199981 830880981 367241232 57161002 550510139 120327439 186258690 809283515 227915662 506674645 430185166 372234930 650467661 69593303 51637417 704635555 894789119 531...
output:
60396928745198318213258
result:
ok single line: '60396928745198318213258'
Test #5:
score: 5
Accepted
time: 4ms
memory: 30504kb
input:
500 998970591 594389705 43008089 396347059 986339673 905846754 807045742 470917409 639614371 637270684 136879653 58845444 425605406 777235535 28588928 139911753 103232624 154106955 961479631 886521757 107881189 253056135 620990994 615378167 665480349 722387860 856766009 760620628 65813484 801372010 ...
output:
60301465403020284987744
result:
ok single line: '60301465403020284987744'
Test #6:
score: 5
Accepted
time: 4ms
memory: 30320kb
input:
500 989354834 660461 1884309 2515211 2982180 6020191 8648567 9104058 9622568 11387149 15218527 15757206 15839199 17545553 18657144 23829639 23974929 24203477 25293790 29677662 31112007 32068246 33915814 39839268 40549810 42735311 43467522 44090402 46074234 48410214 49938093 51091987 52098376 5237871...
output:
40532371095490200672323
result:
ok single line: '40532371095490200672323'
Test #7:
score: 5
Accepted
time: 4ms
memory: 30456kb
input:
500 995856121 995856021 993286190 992428714 987211623 986866652 973993987 970908624 965906992 962384596 961444659 959872088 959274665 954413029 954237972 952206028 950914253 936598037 936541012 936315259 933876938 931901616 929610770 928438496 928418851 927097736 925343918 922758477 921599847 915514...
output:
41163428747490462739833
result:
ok single line: '41163428747490462739833'
Test #8:
score: 5
Accepted
time: 6ms
memory: 32420kb
input:
500 996970428 55157343 782882347 768451599 768451599 216444512 768451599 26520824 371900895 628553310 870731874 768451599 189471193 371900895 564613440 371900895 870731874 443892194 628553310 515311766 626042362 953946357 371900895 139227361 443892194 766070123 766070123 953946357 953946357 37190089...
output:
56893191095878174612719
result:
ok single line: '56893191095878174612719'
Test #9:
score: 5
Accepted
time: 5ms
memory: 34420kb
input:
500 999683066 223727705 480369708 112292804 481160745 224317240 481725729 45280199 488390505 224431750 489839974 117626392 490591180 224711896 490697505 17917789 491413367 224744745 494790152 118515418 495247247 224837576 505897124 58691469 507771381 225294818 507936116 120348431 508509141 227390703...
output:
53154300124913676131137
result:
ok single line: '53154300124913676131137'
Test #10:
score: 5
Accepted
time: 6ms
memory: 32424kb
input:
500 996680038 197437207 458179304 97398864 458338863 198111821 462929198 47263622 464290325 198266716 467555428 100906560 470063484 199483735 472198668 21866514 472442955 200116781 473511671 101048946 476465465 202606998 477951175 47358497 485263524 203886219 488787675 102911236 490111517 207661861 ...
output:
52269022842767688419390
result:
ok single line: '52269022842767688419390'
Test #11:
score: 5
Accepted
time: 4ms
memory: 30360kb
input:
500 996836518 225663257 487415392 113657597 489627476 229686724 493005821 55589679 494314979 231928299 495884741 113824536 497766188 234758176 499178014 24183623 500198901 237391031 500395616 114684268 501242775 240056411 504928824 57255729 508780751 240102366 510732434 116605228 511761619 241162385...
output:
52901323000404343054947
result:
ok single line: '52901323000404343054947'
Test #12:
score: 5
Accepted
time: 0ms
memory: 32488kb
input:
500 997308361 734384892 487928623 885511190 485978519 732782900 485503315 943352135 485139910 731135061 483452593 884499732 480665632 728846479 470610017 966846915 469944921 726748288 466928565 884344389 466856622 726342874 466668864 941970606 466454046 723150867 464794706 884103531 462749291 723117...
output:
52771619017756982130181
result:
ok single line: '52771619017756982130181'
Test #13:
score: 5
Accepted
time: 6ms
memory: 30288kb
input:
500 998995500 707934238 443951641 841012116 443699773 707580586 443209459 924668947 442662521 706274831 442081118 838685438 439562971 705821480 437121050 970118929 432994869 701550583 431651576 838650253 430926740 701508876 419349462 922548610 417491326 696577019 416970255 837263122 413262645 687275...
output:
53853636162421336664462
result:
ok single line: '53853636162421336664462'
Test #14:
score: 5
Accepted
time: 4ms
memory: 30444kb
input:
500 996650138 765626812 453357781 885559897 453256645 761785891 450241520 934514768 446699514 755330669 443755169 884997036 443304254 754923200 434085582 970099818 430508063 754466272 425416574 884513817 424764093 754038009 423164779 934372987 423139345 738573359 422204416 884460993 417674914 732117...
output:
52624776032982600280160
result:
ok single line: '52624776032982600280160'
Test #15:
score: 5
Accepted
time: 0ms
memory: 30420kb
input:
500 999700415 582362183 192179044 534193232 257560075 715029649 684274335 816995706 839543380 688559527 634842016 384705910 136286773 34458146 605084919 279247643 786036528 266661206 203719326 482073421 104473700 627545971 142037098 832947668 418619361 115575142 982412566 388148602 468755125 3841767...
output:
60332370236440636673573
result:
ok single line: '60332370236440636673573'
Subtask #2:
score: 5
Accepted
Dependency #1:
100%
Accepted
Test #16:
score: 5
Accepted
time: 12ms
memory: 33692kb
input:
4000 999415835 325434705 485976668 926029739 370138494 732722191 208960936 412781133 493804459 4441873 29594424 212942231 469635956 113686686 586697026 150736460 253382523 181223360 944337109 416622295 467119741 260653459 645818255 435141298 973596863 434331375 615989573 998308216 741169188 12392168...
output:
3970595078712735751359371
result:
ok single line: '3970595078712735751359371'
Test #17:
score: 5
Accepted
time: 12ms
memory: 31756kb
input:
4000 999802203 649599118 250242603 68728072 326316859 495033111 280504659 609604408 220764914 987811589 424440173 93884997 758158169 950052420 735205708 754774713 403044281 925970729 869867857 793650314 144640266 692849593 268339283 395685942 279053437 386372770 454100953 954177968 293123588 2209313...
output:
3973569086333886235045817
result:
ok single line: '3973569086333886235045817'
Test #18:
score: 5
Accepted
time: 8ms
memory: 33688kb
input:
4000 999877964 366336061 5210161 430101309 335127841 327462116 704349665 757207803 152973338 175661848 115244100 300447019 919391649 774029717 151987390 197961326 457019353 202390579 681204583 808751729 731297172 473513672 36167641 621014106 514616325 491331963 66505607 355272432 776013920 51048286 ...
output:
3974047727292952591000299
result:
ok single line: '3974047727292952591000299'
Test #19:
score: 5
Accepted
time: 10ms
memory: 31620kb
input:
4000 999849325 314868515 254328634 886011412 690249804 131156418 749422062 944497587 939604455 255160614 561080726 368272617 204518254 436529716 59820879 562032608 325312316 181182732 364045397 521201470 285317185 14219931 545598397 506701309 277400987 633623772 703083605 815923782 512555570 6845219...
output:
3974026736738603400578723
result:
ok single line: '3974026736738603400578723'
Test #20:
score: 5
Accepted
time: 8ms
memory: 34636kb
input:
4000 999649683 293143786 404089543 948645960 591213944 420128767 913693955 904637197 90800310 285150476 40950603 561661321 824213238 245828843 95056861 901351197 260851255 529952933 567089905 577858555 278276783 867308618 151221118 542207472 381126520 757554818 581601842 978757967 34224053 402078118...
output:
3972590869295078207458903
result:
ok single line: '3972590869295078207458903'
Test #21:
score: 5
Accepted
time: 4ms
memory: 33752kb
input:
4000 999218074 322817 448108 1286850 1517907 1751394 1933727 1969357 1970595 2180924 2228253 2813059 2819753 2858829 2969167 2991999 3018423 3440367 3644635 3745672 4007786 4030391 4217008 4419577 4425316 4434695 4710215 4740192 5029585 5051326 5197090 5216976 5344821 5757139 5870299 5907179 6286242...
output:
2659476620951389455115559
result:
ok single line: '2659476620951389455115559'
Test #22:
score: 5
Accepted
time: 4ms
memory: 34592kb
input:
4000 999981742 999981642 999695393 999576758 998588017 998141300 997821833 997412364 996967360 996626793 996586318 996507782 996270534 996194469 995965073 995351707 995274486 995102954 994858106 994809057 994205121 993397640 993370901 993229088 992832981 992647741 991702382 991607766 991482261 99135...
output:
2661497262129514677449083
result:
ok single line: '2661497262129514677449083'
Test #23:
score: 5
Accepted
time: 7ms
memory: 35216kb
input:
4000 999998958 80298119 639623534 252373841 252373841 608720231 484025037 942468624 903920599 451221576 188477857 440570903 237556588 80298119 193335644 696786290 639623534 252373841 183942572 788156619 788156619 188397915 203318773 55628357 223723934 188477857 463664308 80298119 696786290 34175503 ...
output:
3860241287673882783928813
result:
ok single line: '3860241287673882783928813'
Test #24:
score: 5
Accepted
time: 3ms
memory: 31660kb
input:
4000 999947196 214942340 464409068 109365821 464921377 214993245 465607259 56260965 465620386 215230440 465885744 109490186 465940347 215301695 465991711 27981930 466373867 215602198 466493112 109789662 467266751 215686242 467670762 56325714 467840457 215712437 467925361 110074398 468260419 21594999...
output:
3392374041798690694758388
result:
ok single line: '3392374041798690694758388'
Test #25:
score: 5
Accepted
time: 8ms
memory: 34980kb
input:
4000 999999487 218682572 490886474 106276872 491038599 219062294 491785864 52115263 491844714 219234571 492390769 106436098 492590218 219475533 493221333 27006922 493446981 219607721 493480680 106511961 493595231 219918468 493679774 52477644 493748411 219937062 493890295 106590281 493897494 22080828...
output:
3404899865741070334696090
result:
ok single line: '3404899865741070334696090'
Test #26:
score: 5
Accepted
time: 4ms
memory: 31684kb
input:
4000 999870525 217442425 477510224 106411508 477897702 217857300 478055519 53847707 478223762 218453183 478530742 106606463 479257650 219043641 479372241 27806875 479563483 219101462 479747067 107088825 479769420 219261547 480193067 53870525 480275186 219453795 480459697 107565396 481178742 21952370...
output:
3398492240577479556055359
result:
ok single line: '3398492240577479556055359'
Test #27:
score: 5
Accepted
time: 10ms
memory: 31644kb
input:
4000 999883955 729352274 461616143 866927797 461561189 729126408 461504230 933802293 461276976 728847649 461137600 866127851 461060925 728573581 461055654 965971255 461007013 728544812 460447099 866048510 460215816 728280963 460090715 933186083 459641714 728063215 459566415 866010625 459427713 72776...
output:
3461503156788610927181394
result:
ok single line: '3461503156788610927181394'
Test #28:
score: 5
Accepted
time: 13ms
memory: 31676kb
input:
4000 999836657 726830261 437428117 864291876 437323121 726389365 436458491 929883217 436151067 726372382 436006434 863853298 435889116 726112171 435354528 959868001 435028691 725992398 434401003 863845895 433804894 725960900 432689843 929715566 432556191 725825927 432181732 862812972 432118481 72538...
output:
3470328507514617180628041
result:
ok single line: '3470328507514617180628041'
Test #29:
score: 5
Accepted
time: 10ms
memory: 34996kb
input:
4000 999709272 728347937 454004519 860864229 453924255 728304682 453916739 931339376 453578314 727171596 453474157 860846212 453070751 727104606 452793137 967850158 452643321 726707831 452573104 860480356 452143802 726689292 452074495 931046885 452001062 726167880 451665383 860026196 451328684 72564...
output:
3459828322351305394151676
result:
ok single line: '3459828322351305394151676'
Test #30:
score: 5
Accepted
time: 8ms
memory: 34716kb
input:
4000 999983168 212171530 317645701 896420454 999983068 927873123 820697889 226091734 339988907 451707831 859400977 940847121 759591226 230435743 587395309 145084943 243699242 137076914 419528394 68029220 329940970 36749752 918563727 667086543 715080242 694075052 521593064 936248720 693562834 3012614...
output:
3975167381683625168594671
result:
ok single line: '3975167381683625168594671'
Subtask #3:
score: 5
Accepted
Test #31:
score: 5
Accepted
time: 1126ms
memory: 367440kb
input:
1000000 2 2 1 1 1 2 2 2 2 2 2 2 1 2 2 1 1 1 2 2 2 2 1 2 2 1 2 1 2 1 2 1 1 2 2 2 2 1 2 2 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 2 2 2 2 1 2 1 2 2 2 2 2 1 1 1 2 1 1 1 2 1 1 1 2 2 2 2 2 2 1 1 2 1 1 2 2 2 2 2 1 1 2 1 1 1 2 1 1 2 1 1 1 2 2 2 2 1 1 1 2 1 1 1 2 2 2 2 1 2 2 1 2 1 2 2 2 1 1 2 2 1 1 2 2 1 1 1 1 1 2 ...
output:
1499999500314
result:
ok single line: '1499999500314'
Test #32:
score: 5
Accepted
time: 1115ms
memory: 367924kb
input:
1000000 2 1 1 1 2 1 2 1 1 2 2 1 2 2 2 1 2 2 1 1 2 2 2 2 2 1 1 2 1 2 2 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 1 1 2 2 2 1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 1 1 1 2 2 1 2 2 2 1 1 1 2 1 1 2 1 2 2 1 2 1 1 2 2 2 1 1 1 2 2 1 2 2 2 2 2 2 1 1 1 2 2 1 2 1 1 1 2 2 1 1 1 1 1 2 1 2 1 1 1 2 1 1 2 2 1 2 1 2 1 2 1 1 2 2 1 ...
output:
1499999506039
result:
ok single line: '1499999506039'
Test #33:
score: 5
Accepted
time: 1114ms
memory: 367960kb
input:
1000000 2 2 2 1 2 2 1 1 2 2 1 2 1 2 2 1 2 1 1 2 1 2 1 1 1 2 1 1 2 2 1 1 1 1 1 2 1 2 2 2 2 2 1 1 1 2 2 1 2 1 1 1 2 2 2 1 2 2 2 2 2 1 1 1 2 1 2 2 1 2 1 2 1 2 1 1 2 1 2 2 1 2 2 2 2 1 2 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 2 1 2 2 2 1 2 2 2 1 2 1 1 2 2 1 2 2 1 2 2 2 1 2 1 1 2 2 2 2 2 1 2 2 2 2 2 1 2 1 2 1 ...
output:
1499999502685
result:
ok single line: '1499999502685'
Test #34:
score: 5
Accepted
time: 1143ms
memory: 368152kb
input:
1000000 2 2 1 2 2 2 1 2 1 2 2 2 2 2 2 1 1 1 1 2 1 2 1 2 1 1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 2 1 2 2 1 2 2 2 1 2 1 1 1 2 2 2 2 1 1 1 2 2 2 1 1 1 1 1 2 2 1 1 2 2 2 1 2 2 1 2 1 1 2 2 2 2 2 2 1 2 1 1 1 2 2 2 1 1 2 2 2 1 1 1 1 1 1 2 2 2 2 1 1 2 1 2 2 1 1 2 1 2 2 2 1 2 2 1 2 1 2 1 2 1 2 2 1 2 1 1 1 1 1 2 1 2 ...
output:
1499999500625
result:
ok single line: '1499999500625'
Test #35:
score: 5
Accepted
time: 1116ms
memory: 367316kb
input:
1000000 2 2 2 2 1 2 2 1 2 1 1 2 1 1 1 2 2 2 2 2 2 2 1 1 2 2 2 2 2 1 1 1 2 1 1 1 1 1 2 2 1 1 2 2 1 1 1 1 2 2 2 1 2 1 1 1 1 1 1 2 1 1 2 2 2 2 2 2 2 1 1 1 2 2 2 1 1 1 1 1 2 2 1 2 2 1 2 1 1 1 2 1 2 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 1 2 1 1 2 1 1 2 1 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 2 2 2 1 1 1 1 1 2 1 2 2 2 2 ...
output:
1499999504912
result:
ok single line: '1499999504912'
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #3:
100%
Accepted
Test #36:
score: 0
Time Limit Exceeded
input:
1000000 50 40 1 23 10 38 24 24 18 4 4 7 29 9 2 38 29 10 8 30 27 46 29 10 23 23 3 49 33 50 27 35 21 26 9 43 30 47 23 19 20 15 44 48 36 35 19 50 17 18 41 26 27 50 8 25 41 28 41 41 3 11 29 42 10 28 8 29 29 2 43 48 34 9 13 2 44 10 23 26 43 1 47 29 47 9 14 14 39 35 11 42 5 30 12 44 47 37 33 37 40 43 36 4...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #41:
score: 10
Accepted
time: 1987ms
memory: 214996kb
input:
500000 999997472 323565887 829841159 316294741 207123786 197822285 87425904 283234947 457350978 346818392 59983222 782455248 784568068 729477373 116544863 669509195 402486856 202576480 122339471 760623311 842345622 481616662 856729905 50173442 129883284 52084768 196396910 320675364 895095006 6623157...
output:
62494142856139796619073017185
result:
ok single line: '62494142856139796619073017185'
Test #42:
score: 10
Accepted
time: 1985ms
memory: 215688kb
input:
500000 999999553 667453610 985296846 471867206 423696432 233164549 154579933 367256868 728088881 476194023 677038635 749157071 751430375 85313530 331919642 246642439 391435901 997652469 559113830 384029939 555439403 475608681 457340998 228043331 131094541 41708960 940467763 396070120 622422171 78747...
output:
62494406715437396311893377081
result:
ok single line: '62494406715437396311893377081'
Test #43:
score: 0
Time Limit Exceeded
input:
500000 999998743 464862541 664034699 394902484 584423210 493215309 106482211 523666077 670018355 601304012 709311860 588414424 927001567 173321522 869869225 562063292 734075465 368832112 112786699 479176298 601727933 384016812 307112969 458188366 380837831 40405318 149226410 955683156 187817692 8302...
output:
62494301541996963734473914707
result:
Subtask #6:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #46:
score: 20
Accepted
time: 310ms
memory: 77324kb
input:
100000 999993517 598790459 537183965 68335700 591512847 918579772 779728634 48635238 740788103 407135955 819858816 563534822 567426511 517675399 559397183 296013105 923989546 259659935 728984034 189521707 829247701 283361594 213446040 199487702 371296223 366945332 121551756 10042853 341828937 107625...
output:
2499023948226277145506670339
result:
ok single line: '2499023948226277145506670339'
Test #47:
score: 20
Accepted
time: 308ms
memory: 79104kb
input:
100000 1000000000 228638491 342616552 266382758 5620534 331715907 171982354 517556742 898641868 893053146 367319613 259209178 24105248 620120127 162182814 260734438 456868228 928250275 433673591 102770151 141638275 371115215 884752629 84165921 263475491 604184639 723208585 466771639 977658195 341406...
output:
2499058342036176563445261927
result:
ok single line: '2499058342036176563445261927'
Test #48:
score: 20
Accepted
time: 302ms
memory: 77176kb
input:
100000 999993562 774238858 163464263 230752092 408034190 495695380 629066311 72378650 926166525 472820642 167046472 620544068 289242404 88988859 40931951 559244087 148475563 619694680 602826768 439388468 135675054 864788457 833456553 634132595 381781768 110222994 466984438 319714467 54903233 1539095...
output:
2499024285320100699543949927
result:
ok single line: '2499024285320100699543949927'
Test #49:
score: 20
Accepted
time: 305ms
memory: 77332kb
input:
100000 999977575 440316497 909968433 759958606 4576290 489575973 457463493 771829864 211997526 82253332 402192606 706897977 236511354 979476305 251882596 177304903 780317568 170605235 98992665 703024310 531079 929286317 977712751 372337703 444874080 591144838 162612317 29869947 52675990 205247058 33...
output:
2498943155127844474124965206
result:
ok single line: '2498943155127844474124965206'
Test #50:
score: 20
Accepted
time: 307ms
memory: 77264kb
input:
100000 999982412 574843805 326482 521329603 541304676 902554609 840100877 791913133 889911995 48623127 229926099 184005818 912782982 309194325 842293045 563458953 906453280 817706701 5036583 265909915 493187390 888003651 402029109 487425451 578006353 457563267 768631159 793134694 301549180 383641077...
output:
2498966815278645425457031022
result:
ok single line: '2498966815278645425457031022'
Test #51:
score: 20
Accepted
time: 97ms
memory: 77272kb
input:
100000 999977998 2451 5660 6122 15876 15878 16927 25109 37029 48545 50068 59046 64887 68970 73887 79793 84821 91133 91692 92448 93053 97647 102604 110023 119978 137892 142562 144540 156431 161115 183617 190234 216247 218827 220156 236005 243839 247102 259763 264579 276364 279000 281951 293441 307885...
output:
1662901433801840811138768796
result:
ok single line: '1662901433801840811138768796'
Test #52:
score: 20
Accepted
time: 101ms
memory: 77272kb
input:
100000 999998336 999998236 999988614 999986594 999985837 999956264 999955082 999946593 999942913 999931615 999917014 999895181 999886402 999866103 999862849 999861375 999853359 999847466 999843175 999813003 999803665 999800225 999793929 999785092 999770201 999748922 999747280 999741188 999709688 999...
output:
1662489461317694235716115907
result:
ok single line: '1662489461317694235716115907'
Test #53:
score: 20
Accepted
time: 229ms
memory: 76560kb
input:
100000 999957623 446810386 821543315 100399296 587500888 895104175 868516855 946002331 781682911 507245685 578791020 611566484 537817388 248645058 712082644 780469663 525473449 712082644 616400268 796565250 99256758 62457143 446805472 928836180 756185122 822701847 310766718 406043292 949612509 51481...
output:
2484109152497159511916644641
result:
ok single line: '2484109152497159511916644641'
Test #54:
score: 20
Accepted
time: 128ms
memory: 77204kb
input:
100000 999994277 281898679 630126597 142553898 281915375 630127001 71267112 281919938 630128155 142560906 281920542 630159000 35303546 281931516 630160661 142565083 281932199 630169727 71281342 281946839 630180393 142565618 281956414 630227849 17437135 281961762 630234503 142572511 281964793 6302454...
output:
2183642082294724399987613045
result:
ok single line: '2183642082294724399987613045'
Test #55:
score: 20
Accepted
time: 125ms
memory: 78824kb
input:
100000 999989935 281824492 630732578 140813734 281826924 630734141 69392416 281841389 630737498 140824745 281843264 630755465 34412684 281871957 630759373 140830416 281886105 630763025 69401629 281893721 630763528 140835959 281909546 630792661 17006964 281915507 630795726 140861060 281916302 6308032...
output:
2183769234221601045239518166
result:
ok single line: '2183769234221601045239518166'
Test #56:
score: 20
Accepted
time: 135ms
memory: 77040kb
input:
100000 999987678 281725806 632151301 140712805 281732383 632155953 69283754 281737209 632182415 140719751 281750239 632182932 34977356 281750468 632194469 140727664 281756619 632197101 69284308 281765670 632217723 140738076 281765774 632239068 17702922 281801935 632251088 140747614 281802482 6322631...
output:
2182903070453698278314708450
result:
ok single line: '2182903070453698278314708450'
Test #57:
score: 20
Accepted
time: 124ms
memory: 77192kb
input:
100000 999996529 648747031 295151456 824446917 648742536 295149513 913074050 648720054 295145623 824428193 648714328 295136686 956036335 648714121 295134544 824404550 648712884 295127399 913069066 648711418 295091129 824403429 648710149 295074229 978051246 648709094 295072495 824395134 648687304 295...
output:
2210236369225836428102049853
result:
ok single line: '2210236369225836428102049853'
Test #58:
score: 20
Accepted
time: 124ms
memory: 77240kb
input:
100000 999990094 647869938 296015868 823938266 647864237 296005968 912569107 647862123 296000511 823932479 647861955 295994770 956007004 647856432 295978580 823921291 647853062 295976664 912564165 647838184 295973140 823909637 647826660 295955563 977860577 647823348 295933740 823886750 647821581 295...
output:
2210984650161167649271540660
result:
ok single line: '2210984650161167649271540660'
Test #59:
score: 20
Accepted
time: 131ms
memory: 78948kb
input:
100000 999994348 649084114 296653978 822986271 649074322 296650018 911479084 649070948 296649224 822978103 649069705 296640329 955840774 649059329 296625221 822964545 649055630 296575438 911470886 649050628 296570515 822959340 649044596 296566986 978186172 649033537 296553202 822917858 649023017 296...
output:
2212041173434475498073650808
result:
ok single line: '2212041173434475498073650808'
Test #60:
score: 20
Accepted
time: 303ms
memory: 77256kb
input:
100000 999994910 402614565 872918387 479539441 918569383 303408166 464271786 595082956 949339001 417522902 263277467 322516311 76083352 443960075 100777481 178873091 145969229 362760923 860245864 142129279 315660521 484105242 575119623 730203830 313225238 463216216 940743776 808572493 207747033 5913...
output:
2499029187162010067381946992
result:
ok single line: '2499029187162010067381946992'
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
0%