QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#950974 | #10184. 넘버링 | QZJ123456 | 100 ✓ | 1164ms | 245440kb | C++14 | 2.8kb | 2025-03-25 19:55:25 | 2025-03-25 19:55:26 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int n,m;
struct edge{
int to,lst;
}e[4000005];
int lst[1000005],tt=1;
vector<int>vec[1000005];
int siz[1000005],bel[1000005];
void add(int x,int y){
e[++tt].to=y;
e[tt].lst=lst[x];
lst[x]=tt;
}
int dfn[1000005],low[1000005],tim,stk[1000005],tp,sz[1000005];
int cc;
void dfs(int now,int lt){
low[now]=dfn[now]=++tim;
stk[++tp]=now;
for(int u=lst[now];u;u=e[u].lst){
int to=e[u].to;
if(!dfn[to])dfs(to,u),low[now]=min(low[now],low[to]);
else if(u!=(lt^1))low[now]=min(low[now],dfn[to]);
}
if(low[now]==dfn[now]){
cc++;
while(tp>0){
int u=stk[tp--];
bel[u]=cc;siz[cc]++;
if(now==u)break;
}
}
}
ll f[1000005],ans;
void solve(int now,int fa){
sz[now]=siz[now];
f[now]=0;
for(auto to:vec[now]){
if(to==fa)continue;
solve(to,now);
sz[now]+=sz[to];
}
for(auto to:vec[now]){
if(to==fa)continue;
f[now]=max(f[now],f[to]+(ll)(sz[now]-sz[to])*sz[to]);
}
}
ll val[1000005];
struct line{
ll k,b;
}line[1000005];
int ls[20000005],rs[20000005],best[20000005],rt,tot;
ll calc(int id,int x){
return line[id].k*x+line[id].b;
}
void ins(int &p,int l,int r,int id){
if(!p)p=++tot;
int mid=l+r>>1;
if(calc(id,mid)>calc(best[p],mid))swap(id,best[p]);
if(l==r)return;
if(calc(id,l)>calc(best[p],l))ins(ls[p],l,mid,id);
if(calc(id,r)>calc(best[p],r))ins(rs[p],mid+1,r,id);
}
ll Get(int p,int l,int r,int x){
ll res=calc(best[p],x);
if(l==r)return res;
int mid=l+r>>1;
if(x<=mid)res=max(res,Get(ls[p],l,mid,x));
else res=max(res,Get(rs[p],mid+1,r,x));
return res;
}
void clr(){
for(int i=1;i<=tot;i++)best[i]=ls[i]=rs[i]=0;
tot=rt=0;
}
void change(int now,int fa){
if(now!=1){
int res=n-sz[now];
f[now]=val[now]+(ll)(n-res)*res;
for(auto to:vec[now]){
if(to==fa)continue;
f[now]=max(f[now],f[to]+(ll)(n-sz[to])*sz[to]);
}
for(auto to:vec[now])if(to!=fa)val[to]=val[now]+(ll)(sz[now]-sz[to])*res;
}
ans=max(ans,f[now]);
clr();
for(auto to:vec[now]){
if(to==fa)continue;
line[to].k=sz[to],line[to].b=f[to]-(ll)sz[to]*sz[to];
val[to]=max(val[to],Get(rt,1,n,n-sz[to]));
ins(rt,1,n,to);
}
reverse(vec[now].begin(),vec[now].end());
clr();
for(auto to:vec[now]){
if(to==fa)continue;
val[to]=max(val[to],Get(rt,1,n,n-sz[to]));
ins(rt,1,n,to);
}
for(auto to:vec[now]){
if(to==fa)continue;
change(to,now);
}
}
ll max_diversity(int N, int M, vector<int> U, vector<int> V){n=N,m=M;
line[0].b=-1e18;
for(int i=0;i<m;i++){
int x=U[i],y=V[i];x++,y++;
add(x,y);
add(y,x);
}
dfs(1,0);
for(int i=1;i<=n;i++){
for(int u=lst[i];u;u=e[u].lst){
if(bel[i]!=bel[e[u].to])vec[bel[i]].push_back(bel[e[u].to]);
}
}
solve(1,0);
change(1,0);
return ans;
}
詳細信息
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 3ms
memory: 42772kb
input:
500 499 459 386 278 82 464 462 358 12 298 150 102 304 180 273 424 428 151 360 79 162 432 430 434 203 35 271 62 485 360 45 116 102 154 318 64 446 31 279 143 317 238 91 238 355 486 482 281 30 320 494 393 79 276 354 262 437 364 150 22 137 440 32 128 412 88 354 286 156 206 434 327 52 193 157 250 363 299...
output:
116703
result:
ok single line: '116703'
Test #2:
score: 1
Accepted
time: 3ms
memory: 44820kb
input:
500 499 87 231 228 59 26 35 342 0 157 332 246 355 270 2 439 49 77 419 301 211 180 208 443 383 392 183 283 50 481 415 330 372 241 250 469 354 261 150 381 236 31 205 123 309 482 257 92 274 246 153 211 27 61 378 158 184 455 475 81 453 143 45 167 498 311 16 275 76 9 68 172 338 16 372 329 497 447 255 18 ...
output:
114594
result:
ok single line: '114594'
Test #3:
score: 1
Accepted
time: 4ms
memory: 44824kb
input:
500 499 11 371 281 37 280 3 17 180 313 15 185 99 168 244 58 467 492 373 319 451 121 485 452 266 157 199 5 411 293 285 56 155 136 386 282 455 491 225 322 143 335 116 108 264 171 341 200 110 160 120 325 79 155 303 362 418 342 96 436 257 154 459 2 480 342 73 60 200 108 394 221 125 31 384 396 427 107 33...
output:
114374
result:
ok single line: '114374'
Test #4:
score: 1
Accepted
time: 2ms
memory: 42680kb
input:
500 499 42 475 59 153 221 72 348 186 451 215 438 34 2 455 458 294 109 217 384 435 439 464 15 216 496 91 49 7 340 360 53 66 12 11 239 289 477 445 409 221 349 105 93 12 411 361 313 104 20 231 229 324 395 7 226 202 211 244 112 174 134 38 48 231 212 55 400 305 378 233 271 317 363 316 471 344 252 44 60 2...
output:
124750
result:
ok single line: '124750'
Test #5:
score: 1
Accepted
time: 5ms
memory: 42804kb
input:
500 499 153 39 417 197 13 415 122 493 326 283 90 405 345 216 190 472 111 68 316 179 40 481 255 247 371 365 65 475 15 452 242 240 127 278 173 379 403 464 173 256 298 287 252 213 338 277 49 333 434 158 126 276 461 345 28 360 141 83 422 243 448 175 5 418 116 297 209 344 483 0 459 399 130 169 33 116 336...
output:
124750
result:
ok single line: '124750'
Test #6:
score: 1
Accepted
time: 3ms
memory: 42804kb
input:
500 499 455 185 98 169 259 41 162 63 32 299 128 216 497 461 191 344 364 421 13 281 101 313 327 394 108 28 321 22 399 38 97 362 330 438 205 163 497 7 158 157 11 225 260 203 204 290 332 270 219 459 38 499 309 160 378 56 223 80 283 236 111 374 31 435 448 103 478 408 154 398 0 370 236 70 68 418 76 157 2...
output:
124750
result:
ok single line: '124750'
Subtask #2:
score: 4
Accepted
Test #7:
score: 4
Accepted
time: 4ms
memory: 47112kb
input:
5000 4999 2322 3285 4441 4024 4765 4417 2709 3777 3090 1345 3505 582 498 2980 726 1750 781 4189 2055 3192 2724 619 3054 2028 4390 618 3292 1768 4555 681 2325 1580 4460 2739 3209 4766 713 4438 3173 4864 2577 1398 232 3661 4062 2003 6 2503 222 1958 3633 4964 2955 4536 3090 4084 3268 2892 852 2925 2882...
output:
11617857
result:
ok single line: '11617857'
Test #8:
score: 4
Accepted
time: 3ms
memory: 44996kb
input:
5000 4999 3450 2130 4186 1206 1315 3194 4693 2766 2245 527 3944 325 589 2117 3753 4667 3504 1747 73 945 4177 3397 563 3707 3247 3531 4001 821 1972 551 1551 1851 4855 1171 2214 175 443 4513 2706 2270 3678 4513 1013 2307 3059 790 4114 1747 3136 425 1746 912 241 1461 3283 1319 4859 2217 4411 3433 1585 ...
output:
10729580
result:
ok single line: '10729580'
Test #9:
score: 4
Accepted
time: 5ms
memory: 44944kb
input:
5000 4999 1874 1782 4740 684 1376 1971 1676 1754 1809 2005 4384 877 3383 1654 564 2584 418 1201 795 185 2925 3879 3072 3090 4808 3739 3222 3386 1284 2718 777 2929 2146 2307 4323 4775 173 1884 4944 2381 1267 731 4498 4466 1247 1874 3629 991 3754 3084 668 4964 3334 2985 1179 3553 1450 3838 1754 1237 3...
output:
11427963
result:
ok single line: '11427963'
Test #10:
score: 4
Accepted
time: 5ms
memory: 43412kb
input:
5000 4999 1345 937 4027 3952 1625 128 3245 4533 3150 2088 4847 3171 2785 362 916 2332 942 829 3118 2364 616 1001 4210 4123 2579 928 4382 1916 3648 4645 4755 2473 1288 636 2988 1091 183 1363 682 2719 656 4621 1652 156 4212 4459 3071 4446 4141 3216 3230 1334 4709 4170 2612 2121 780 791 4166 1592 832 4...
output:
12497500
result:
ok single line: '12497500'
Test #11:
score: 4
Accepted
time: 6ms
memory: 43408kb
input:
5000 4999 682 4225 4640 2509 2772 56 3695 484 2782 4337 4528 4535 3064 1394 3152 1532 3938 3615 3805 4443 659 2595 4573 3149 1582 4737 2579 4643 102 250 4549 2449 3135 4339 423 3877 2094 2527 4767 1604 2981 2575 1726 33 3118 10 769 1108 1520 1201 1786 73 2683 4789 4648 1308 927 2432 3954 777 4625 47...
output:
12497500
result:
ok single line: '12497500'
Test #12:
score: 4
Accepted
time: 6ms
memory: 45328kb
input:
5000 4999 1501 32 3528 4046 3325 3721 912 1797 513 2678 1247 4718 2325 4516 3145 3230 3419 3238 1859 2060 2399 1917 3839 3299 3154 1785 3265 346 4199 1191 808 409 1051 4082 4357 3638 3720 3223 1386 3837 3949 4072 4301 3704 1427 3481 83 1142 4123 3738 3719 4313 4837 1586 3346 3713 4915 1349 4343 1533...
output:
12497500
result:
ok single line: '12497500'
Subtask #3:
score: 5
Accepted
Test #13:
score: 5
Accepted
time: 907ms
memory: 148712kb
input:
1000000 999999 924457 882941 165670 642317 495093 733339 171328 277620 200104 60427 281019 191189 825062 582547 29928 311344 205576 229260 713481 245720 218203 678052 467987 734837 46302 661083 686963 395843 225671 507977 315462 259089 186495 794327 841759 942147 125089 757889 994885 66961 725119 83...
output:
470279786444
result:
ok single line: '470279786444'
Test #14:
score: 5
Accepted
time: 907ms
memory: 148564kb
input:
1000000 999999 7881 399081 170416 304498 620155 244820 167503 428904 166964 364610 541459 750932 625153 376276 251 759261 486003 476818 176907 318473 506143 825829 575497 609220 360159 971292 781184 44896 939984 775143 834688 545167 528786 737759 676572 312555 927115 987964 614826 824367 165412 4247...
output:
454213466889
result:
ok single line: '454213466889'
Test #15:
score: 5
Accepted
time: 877ms
memory: 148732kb
input:
1000000 999999 91305 947925 950970 933976 969408 723597 939486 869788 101119 701496 834603 277972 457947 978518 194766 464074 957917 981272 574925 582713 569892 6311 683006 450899 706720 314204 842701 469757 430104 75014 353914 55438 614181 713895 702872 907155 794549 185335 202064 581774 381513 818...
output:
456282085714
result:
ok single line: '456282085714'
Test #16:
score: 5
Accepted
time: 1137ms
memory: 245440kb
input:
1000000 999999 850053 659019 42058 807681 130670 184344 471067 824281 946899 622493 321955 627726 137441 549739 651874 360798 820362 157970 886658 488115 413006 47794 9480 816767 360025 663321 324715 257129 413141 19264 667514 67530 134643 70250 134127 987093 880916 570674 740456 918306 609348 76378...
output:
499999500000
result:
ok single line: '499999500000'
Test #17:
score: 5
Accepted
time: 1137ms
memory: 243900kb
input:
1000000 999999 376735 933748 562245 73738 447750 63716 991711 627307 473914 476458 881906 541545 77102 871820 259330 127534 708257 600036 499392 820242 229191 428060 162462 476109 143071 128671 155755 151334 278721 526998 645627 978030 703592 596350 578069 746136 468545 864193 369681 468638 450275 5...
output:
499999500000
result:
ok single line: '499999500000'
Test #18:
score: 5
Accepted
time: 1164ms
memory: 245400kb
input:
1000000 999999 883209 153457 118839 780747 747161 159991 546594 28592 486425 927304 87909 197543 483359 456123 96067 667161 375330 168980 757740 938029 112790 716506 339841 524852 792424 976694 150617 893483 82834 46497 626452 15570 581884 585578 783194 533186 600793 635213 115561 20633 922632 30244...
output:
499999500000
result:
ok single line: '499999500000'
Subtask #4:
score: 3
Accepted
Test #19:
score: 3
Accepted
time: 3ms
memory: 42780kb
input:
500 499 459 388 459 411 459 361 459 17 459 387 459 207 459 110 459 350 459 163 459 230 459 130 459 406 459 415 459 491 459 321 459 384 459 435 459 456 459 315 459 0 459 165 459 347 459 436 459 64 459 465 459 40 459 65 459 454 459 193 459 466 459 42 459 475 459 488 459 271 459 317 459 371 459 156 459...
output:
997
result:
ok single line: '997'
Test #20:
score: 3
Accepted
time: 4ms
memory: 44820kb
input:
500 499 87 399 87 459 87 17 87 26 87 400 87 386 87 104 87 469 87 361 87 220 87 363 87 451 87 222 87 140 87 489 87 466 87 329 87 8 87 484 87 257 87 167 87 44 87 31 87 453 87 414 87 378 87 429 87 106 87 486 87 211 87 490 87 93 87 145 87 427 87 270 87 425 87 304 87 331 87 15 87 452 87 199 87 435 87 32 ...
output:
997
result:
ok single line: '997'
Test #21:
score: 3
Accepted
time: 4ms
memory: 44820kb
input:
500 499 11 414 11 182 11 466 11 261 11 493 11 333 11 375 11 218 11 257 11 119 11 132 11 249 11 243 11 449 11 266 11 33 11 383 11 24 11 491 11 239 11 467 11 244 11 474 11 214 11 359 11 164 11 212 11 123 11 276 11 402 11 171 11 8 11 152 11 356 11 219 11 459 11 25 11 64 11 313 11 101 11 88 11 136 11 49...
output:
997
result:
ok single line: '997'
Test #22:
score: 3
Accepted
time: 4ms
memory: 42772kb
input:
500 499 459 386 278 82 464 462 358 12 298 150 102 304 180 273 424 428 151 360 79 162 432 430 434 203 35 271 62 485 360 45 116 102 154 318 64 446 31 279 143 317 238 91 238 355 486 482 281 30 320 494 393 79 276 354 262 437 364 150 22 137 440 32 128 412 88 354 286 156 206 434 327 52 193 157 250 363 299...
output:
115983
result:
ok single line: '115983'
Test #23:
score: 3
Accepted
time: 2ms
memory: 42776kb
input:
500 499 87 231 228 59 26 35 342 0 157 332 246 355 270 2 439 49 77 419 301 211 180 208 443 383 392 183 283 50 481 415 330 372 241 250 469 354 261 150 381 236 31 205 123 309 482 257 92 274 246 153 211 27 61 378 158 184 455 475 81 453 143 45 167 498 311 16 275 76 9 68 172 338 16 372 329 497 447 255 18 ...
output:
114377
result:
ok single line: '114377'
Test #24:
score: 3
Accepted
time: 4ms
memory: 42520kb
input:
500 499 11 371 281 37 280 3 17 180 313 15 185 99 168 244 58 467 492 373 319 451 121 485 452 266 157 199 5 411 293 285 56 155 136 386 282 455 491 225 322 143 335 116 108 264 171 341 200 110 160 120 325 79 155 303 362 418 342 96 436 257 154 459 2 480 342 73 60 200 108 394 221 125 31 384 396 427 107 33...
output:
116258
result:
ok single line: '116258'
Subtask #5:
score: 5
Accepted
Test #25:
score: 5
Accepted
time: 5ms
memory: 46940kb
input:
5000 4999 2322 1237 2322 2854 2322 911 2322 3699 2322 4352 2322 3259 2322 3117 2322 2811 2322 4848 2322 4614 2322 8 2322 471 2322 1340 2322 1517 2322 3080 2322 4560 2322 3 2322 691 2322 410 2322 4280 2322 1072 2322 2375 2322 584 2322 3759 2322 2712 2322 2444 2322 2599 2322 638 2322 2793 2322 2536 23...
output:
9997
result:
ok single line: '9997'
Test #26:
score: 5
Accepted
time: 4ms
memory: 42920kb
input:
5000 4999 3450 4582 3450 546 3450 383 3450 3168 3450 4762 3450 926 3450 16 3450 4014 3450 3272 3450 3585 3450 80 3450 4148 3450 1405 3450 4825 3450 4885 3450 3485 3450 2698 3450 101 3450 2134 3450 3518 3450 4465 3450 1272 3450 1376 3450 2459 3450 1004 3450 2043 3450 115 3450 2721 3450 1766 3450 1533...
output:
9997
result:
ok single line: '9997'
Test #27:
score: 5
Accepted
time: 4ms
memory: 43048kb
input:
5000 4999 1874 972 1874 4170 1874 2321 1874 4402 1874 1879 1874 1850 1874 1517 1874 124 1874 4448 1874 3872 1874 2734 1874 2251 1874 2058 1874 273 1874 3784 1874 1774 1874 2367 1874 4215 1874 784 1874 2586 1874 2424 1874 3333 1874 1079 1874 2569 1874 485 1874 960 1874 3270 1874 4295 1874 978 1874 31...
output:
9997
result:
ok single line: '9997'
Test #28:
score: 5
Accepted
time: 6ms
memory: 43024kb
input:
5000 4999 2322 3285 4441 4024 4765 4417 2709 3777 3090 1345 3505 582 498 2980 726 1750 781 4189 2055 3192 2724 619 3054 2028 4390 618 3292 1768 4555 681 2325 1580 4460 2739 3209 4766 713 4438 3173 4864 2577 1398 232 3661 4062 2003 6 2503 222 1958 3633 4964 2955 4536 3090 4084 3268 2892 852 2925 2882...
output:
11264923
result:
ok single line: '11264923'
Test #29:
score: 5
Accepted
time: 5ms
memory: 44940kb
input:
5000 4999 3450 2130 4186 1206 1315 3194 4693 2766 2245 527 3944 325 589 2117 3753 4667 3504 1747 73 945 4177 3397 563 3707 3247 3531 4001 821 1972 551 1551 1851 4855 1171 2214 175 443 4513 2706 2270 3678 4513 1013 2307 3059 790 4114 1747 3136 425 1746 912 241 1461 3283 1319 4859 2217 4411 3433 1585 ...
output:
11239160
result:
ok single line: '11239160'
Test #30:
score: 5
Accepted
time: 5ms
memory: 44944kb
input:
5000 4999 1874 1782 4740 684 1376 1971 1676 1754 1809 2005 4384 877 3383 1654 564 2584 418 1201 795 185 2925 3879 3072 3090 4808 3739 3222 3386 1284 2718 777 2929 2146 2307 4323 4775 173 1884 4944 2381 1267 731 4498 4466 1247 1874 3629 991 3754 3084 668 4964 3334 2985 1179 3553 1450 3838 1754 1237 3...
output:
11394317
result:
ok single line: '11394317'
Subtask #6:
score: 28
Accepted
Test #31:
score: 28
Accepted
time: 446ms
memory: 152788kb
input:
1000000 999999 924457 618993 924457 556851 924457 830052 924457 77540 924457 556952 924457 534458 924457 655527 924457 648657 924457 645503 924457 740124 924457 193313 924457 912596 924457 34483 924457 816939 924457 788296 924457 763751 924457 935675 924457 1584 924457 324051 924457 40140 924457 429...
output:
1999997
result:
ok single line: '1999997'
Test #32:
score: 28
Accepted
time: 438ms
memory: 152792kb
input:
1000000 999999 7881 140122 7881 171073 7881 69210 7881 518169 7881 998420 7881 321516 7881 3717 7881 447226 7881 359737 7881 254007 7881 493579 7881 508802 7881 597503 7881 347232 7881 968053 7881 565857 7881 122576 7881 515059 7881 383250 7881 545267 7881 116296 7881 662683 7881 791815 7881 380715 ...
output:
1999997
result:
ok single line: '1999997'
Test #33:
score: 28
Accepted
time: 451ms
memory: 150740kb
input:
1000000 999999 91305 821753 91305 178129 91305 583399 91305 682886 91305 500814 91305 535582 91305 699362 91305 60436 91305 667343 91305 175747 91305 723931 91305 834132 91305 534428 91305 579485 91305 926651 91305 942011 91305 83406 91305 762950 91305 803127 91305 916736 91305 121 91305 837972 9130...
output:
1999997
result:
ok single line: '1999997'
Test #34:
score: 28
Accepted
time: 851ms
memory: 148968kb
input:
1000000 999999 924457 882941 165670 642317 495093 733339 171328 277620 200104 60427 281019 191189 825062 582547 29928 311344 205576 229260 713481 245720 218203 678052 467987 734837 46302 661083 686963 395843 225671 507977 315462 259089 186495 794327 841759 942147 125089 757889 994885 66961 725119 83...
output:
480973768678
result:
ok single line: '480973768678'
Test #35:
score: 28
Accepted
time: 865ms
memory: 149092kb
input:
1000000 999999 7881 399081 170416 304498 620155 244820 167503 428904 166964 364610 541459 750932 625153 376276 251 759261 486003 476818 176907 318473 506143 825829 575497 609220 360159 971292 781184 44896 939984 775143 834688 545167 528786 737759 676572 312555 927115 987964 614826 824367 165412 4247...
output:
461560945592
result:
ok single line: '461560945592'
Test #36:
score: 28
Accepted
time: 857ms
memory: 149048kb
input:
1000000 999999 91305 947925 950970 933976 969408 723597 939486 869788 101119 701496 834603 277972 457947 978518 194766 464074 957917 981272 574925 582713 569892 6311 683006 450899 706720 314204 842701 469757 430104 75014 353914 55438 614181 713895 702872 907155 794549 185335 202064 581774 381513 818...
output:
461183733015
result:
ok single line: '461183733015'
Test #37:
score: 28
Accepted
time: 537ms
memory: 152788kb
input:
1000000 999999 264206 445484 264206 376726 264206 458722 264206 538421 264206 304382 264206 895380 264206 973551 264206 394835 264206 352931 264206 529702 264206 531408 264206 902227 264206 363929 264206 245187 264206 201706 264206 654137 264206 152292 264206 242720 264206 469439 264206 761398 26420...
output:
5999977
result:
ok single line: '5999977'
Test #38:
score: 28
Accepted
time: 542ms
memory: 152568kb
input:
1000000 999999 498788 751816 498788 87282 498788 925856 498788 25687 498788 808513 498788 760088 498788 487509 498788 765892 498788 514515 498788 744005 498788 768013 498788 594319 498788 102332 498788 519656 498788 786984 498788 955918 498788 837222 498788 599243 498788 653128 498788 272765 498788 ...
output:
5999977
result:
ok single line: '5999977'
Test #39:
score: 28
Accepted
time: 533ms
memory: 152788kb
input:
1000000 999999 535526 319248 535526 323670 535526 912472 535526 918340 535526 212359 535526 724965 535526 769672 535526 534731 535526 12510 535526 768342 535526 343814 535526 49746 535526 189966 535526 534111 535526 7518 535526 786422 535526 687786 535526 81816 535526 809535 535526 153322 535526 615...
output:
5999977
result:
ok single line: '5999977'
Subtask #7:
score: 6
Accepted
Test #40:
score: 6
Accepted
time: 3ms
memory: 42768kb
input:
500 503 115 486 179 115 281 134 123 319 88 253 322 208 18 356 371 193 280 410 438 58 349 372 484 183 498 419 364 369 449 37 336 267 27 143 496 123 148 334 167 487 403 149 288 152 152 492 226 106 196 164 164 322 296 409 471 206 290 223 115 428 162 262 434 132 107 242 296 98 212 336 352 408 75 118 381...
output:
52135
result:
ok single line: '52135'
Test #41:
score: 6
Accepted
time: 4ms
memory: 42780kb
input:
500 1000 103 87 233 301 411 75 323 5 463 436 114 197 441 218 358 43 113 377 81 131 306 73 147 161 27 103 39 287 22 61 60 253 192 238 113 244 443 56 294 370 223 199 77 2 349 385 282 341 103 469 395 405 66 111 156 81 430 155 156 27 471 233 110 233 278 175 321 462 379 482 13 6 46 65 92 253 110 486 94 4...
output:
997
result:
ok single line: '997'
Test #42:
score: 6
Accepted
time: 4ms
memory: 44820kb
input:
500 506 192 284 488 86 9 377 394 321 163 162 387 141 414 296 187 239 156 307 64 173 380 47 130 457 34 144 206 75 409 486 339 91 139 386 184 479 473 302 340 391 237 245 255 188 110 189 206 16 495 30 50 394 92 182 341 103 256 316 348 329 33 316 260 287 267 410 489 131 117 458 270 36 366 290 487 310 44...
output:
49405
result:
ok single line: '49405'
Test #43:
score: 6
Accepted
time: 3ms
memory: 44828kb
input:
500 1000 27 135 287 278 473 352 307 289 118 119 54 44 236 459 373 164 28 435 303 75 55 351 169 340 384 15 260 148 335 228 479 24 279 374 222 152 173 119 32 289 27 314 154 352 38 469 93 177 221 128 8 353 351 35 52 316 9 480 499 332 174 339 445 307 13 28 106 393 170 116 166 396 61 77 159 387 270 273 4...
output:
1494
result:
ok single line: '1494'
Test #44:
score: 6
Accepted
time: 2ms
memory: 44816kb
input:
500 509 64 185 296 453 33 27 178 427 47 379 156 469 309 145 15 477 31 205 485 83 319 426 175 424 365 74 345 176 264 424 330 222 151 436 89 336 94 475 25 488 274 149 414 32 272 89 389 427 78 397 40 466 388 251 108 295 221 113 81 434 107 177 278 443 415 170 274 461 123 389 84 267 158 257 400 477 227 3...
output:
34420
result:
ok single line: '34420'
Test #45:
score: 6
Accepted
time: 5ms
memory: 44832kb
input:
500 1000 155 276 237 256 22 321 494 277 274 97 493 288 122 189 196 82 250 186 321 328 303 333 178 415 445 223 277 9 159 406 205 294 274 306 227 252 403 193 473 195 116 428 139 307 443 256 405 421 147 94 326 201 137 59 448 254 100 101 354 136 185 456 485 289 44 393 287 17 269 442 215 387 281 280 238 ...
output:
997
result:
ok single line: '997'
Test #46:
score: 6
Accepted
time: 4ms
memory: 44820kb
input:
500 512 25 387 496 441 234 135 390 99 99 121 86 373 23 73 444 353 342 347 348 355 280 259 180 154 362 271 11 47 10 147 292 460 338 384 125 211 77 465 444 452 89 80 210 118 322 79 350 27 158 433 39 19 19 333 39 89 452 279 281 55 240 358 428 437 290 146 341 362 263 323 102 306 11 341 249 105 152 207 1...
output:
28883
result:
ok single line: '28883'
Test #47:
score: 6
Accepted
time: 4ms
memory: 42616kb
input:
500 1000 79 120 494 426 84 98 465 469 441 483 433 328 212 430 19 499 381 244 339 273 256 110 483 94 494 443 498 62 267 276 123 372 169 239 39 457 132 268 211 102 217 147 420 261 132 340 216 165 61 253 236 456 230 484 344 488 191 222 413 144 388 265 116 67 75 258 72 141 60 76 60 469 296 292 114 247 7...
output:
997
result:
ok single line: '997'
Test #48:
score: 6
Accepted
time: 5ms
memory: 42644kb
input:
500 502 11 371 371 11 281 37 37 281 280 3 3 280 17 180 313 15 185 99 168 244 58 467 492 373 319 451 121 485 452 266 157 199 5 411 293 285 56 155 136 386 282 455 491 225 322 143 335 116 108 264 171 341 200 110 160 120 325 79 155 303 362 418 342 96 436 257 154 459 2 480 342 73 60 200 108 394 221 125 3...
output:
116150
result:
ok single line: '116150'
Test #49:
score: 6
Accepted
time: 5ms
memory: 42768kb
input:
500 505 487 212 212 487 42 366 366 42 144 26 26 144 159 144 144 159 483 61 61 483 16 126 126 16 143 443 423 410 259 240 282 390 262 126 84 200 432 40 464 186 334 296 426 70 113 388 208 167 384 450 343 375 22 371 463 35 45 296 146 434 310 404 474 130 318 276 142 325 102 355 181 182 276 194 212 18 140...
output:
115866
result:
ok single line: '115866'
Test #50:
score: 6
Accepted
time: 3ms
memory: 42772kb
input:
500 508 463 41 41 463 291 3 3 291 417 344 344 417 5 108 108 5 166 108 108 166 39 461 461 39 414 359 359 414 72 57 57 72 118 206 206 118 244 124 404 472 124 337 398 165 424 460 387 407 297 497 295 197 431 276 265 470 55 311 412 319 318 294 123 443 377 462 268 292 19 478 482 45 331 40 466 218 438 310 ...
output:
118826
result:
ok single line: '118826'
Test #51:
score: 6
Accepted
time: 3ms
memory: 40736kb
input:
500 501 270 479 7 395 360 171 78 96 207 4 339 420 84 313 244 362 109 162 400 490 180 99 90 116 445 273 451 240 429 297 141 197 370 69 257 46 461 18 96 108 25 115 61 288 390 200 122 130 460 402 403 411 214 463 414 74 259 468 345 63 218 455 442 439 221 252 75 223 264 40 228 219 355 400 261 292 4 11 39...
output:
0
result:
ok single line: '0'
Test #52:
score: 6
Accepted
time: 5ms
memory: 42788kb
input:
500 502 421 413 411 15 418 404 231 94 291 457 283 36 347 88 203 175 490 106 106 24 402 206 115 221 192 379 286 478 131 453 491 439 469 133 341 435 314 322 136 190 498 16 338 321 237 115 119 396 18 159 461 471 188 90 5 490 380 312 276 289 62 486 93 225 22 430 472 390 485 343 36 416 280 202 56 237 394...
output:
0
result:
ok single line: '0'
Test #53:
score: 6
Accepted
time: 4ms
memory: 40732kb
input:
500 503 366 261 107 336 450 2 230 89 478 299 202 27 15 416 469 370 314 37 327 375 115 198 67 341 130 345 427 387 89 159 313 184 156 137 362 126 252 493 466 470 186 36 62 174 172 163 7 148 458 226 21 153 340 242 451 59 484 61 296 315 116 75 491 435 73 113 389 486 293 489 138 442 32 77 404 40 347 189 ...
output:
0
result:
ok single line: '0'
Test #54:
score: 6
Accepted
time: 4ms
memory: 42612kb
input:
5 5 0 1 0 2 1 2 1 3 2 4
output:
7
result:
ok single line: '7'
Subtask #8:
score: 10
Accepted
Test #55:
score: 10
Accepted
time: 3ms
memory: 43020kb
input:
5000 5010 4720 990 2426 4913 3960 3980 1133 2584 2910 1721 1241 1343 1161 1519 1087 619 2627 1616 2220 896 4653 1224 2018 1914 1633 4126 756 1117 3711 1759 3701 3398 4201 1683 3018 3920 2998 966 2827 3840 4171 1112 1670 1953 1405 2942 4492 1777 3072 2071 3778 1770 891 4887 2146 3090 1186 3719 3535 1...
output:
4495832
result:
ok single line: '4495832'
Test #56:
score: 10
Accepted
time: 4ms
memory: 45232kb
input:
5000 10000 3344 3269 2050 2659 940 320 2664 1830 952 1986 4297 4571 860 61 1013 473 2696 2960 385 4232 3756 2310 4420 4677 4832 4542 1596 4794 172 4 4159 475 2234 2023 2530 4770 3135 2625 30 931 2438 2890 1765 1217 2700 3694 1297 3375 1893 3594 3206 600 4022 1706 2419 2552 1985 1262 861 3865 3156 47...
output:
19990
result:
ok single line: '19990'
Test #57:
score: 10
Accepted
time: 6ms
memory: 44948kb
input:
5000 5020 1989 388 161 940 1991 3932 2104 727 3952 1343 3720 4280 2684 3276 3519 451 4804 4089 4479 1589 1179 2319 3910 4347 1107 4364 4030 291 2893 3152 3198 960 2220 2224 4727 4058 2803 3279 983 52 3386 2304 1906 2301 3381 837 2844 1231 3645 2843 944 811 2805 2411 2276 1915 1694 1195 2195 1863 299...
output:
2899140
result:
ok single line: '2899140'
Test #58:
score: 10
Accepted
time: 6ms
memory: 45096kb
input:
5000 10000 4472 4409 1796 2137 2490 993 4647 818 516 1168 2032 1611 3654 2302 4040 2582 419 3222 1107 1985 4400 87 4226 1356 1393 4750 817 2359 4485 2170 681 3449 4525 455 2343 1666 569 2700 4563 1042 2730 1813 1058 671 889 3969 3109 2619 3319 2061 1320 2356 2115 527 315 4787 871 2883 1717 1669 2667...
output:
24985
result:
ok single line: '24985'
Test #59:
score: 10
Accepted
time: 5ms
memory: 43024kb
input:
5000 5030 4257 4786 2088 2375 2317 1181 3076 3871 2290 1772 4712 1818 2312 840 951 1090 1981 2369 2954 4578 410 2606 3099 2587 172 1497 3112 4464 180 1440 3502 1625 1456 469 1436 3388 2608 2887 628 3559 2601 2007 4845 2648 2653 3732 1195 1093 2729 4423 814 2148 1614 4128 3215 741 4097 2863 3558 4178...
output:
1395808
result:
ok single line: '1395808'
Test #60:
score: 10
Accepted
time: 5ms
memory: 43056kb
input:
5000 10000 2896 957 2349 4319 2551 2066 4334 3998 4671 2647 2472 1355 3744 1031 851 499 2333 4972 4125 1225 3149 569 2543 739 2954 3471 2334 4515 1501 2041 4099 1824 1816 3887 4452 4778 298 479 2609 3449 3831 4927 4543 2830 4078 53 4920 4159 3937 2015 2138 2896 2104 4347 4020 2021 2462 4504 4060 447...
output:
19990
result:
ok single line: '19990'
Test #61:
score: 10
Accepted
time: 4ms
memory: 49164kb
input:
5000 5040 1526 1888 1312 1106 3051 1941 943 4718 627 4098 2599 3948 2347 4892 4192 3626 4157 4841 2917 2976 1936 3701 4991 3123 453 3222 4090 3637 4363 2833 2999 4995 2179 2907 3953 3526 4708 2904 1080 2067 1816 4415 2785 291 4630 1627 355 3251 1814 1004 2979 3485 3528 3948 3345 1862 13 339 2217 339...
output:
1463995
result:
ok single line: '1463995'
Test #62:
score: 10
Accepted
time: 7ms
memory: 43180kb
input:
5000 10000 1320 4802 2903 3796 1805 843 2806 2986 3827 4533 615 3394 3835 569 1174 3416 2760 234 2143 3170 1897 4155 2756 1611 1811 3679 1555 1272 3917 2719 3325 2094 2211 2320 3456 1674 28 2850 2550 1663 4124 1146 2620 2284 778 1136 1732 699 1851 3186 2547 4652 1685 1679 4212 1960 1349 3829 4915 79...
output:
29979
result:
ok single line: '29979'
Test #63:
score: 10
Accepted
time: 7ms
memory: 42896kb
input:
5000 5019 4022 2956 2956 4022 1942 727 727 1942 1970 517 517 1970 3850 1492 1492 3850 2183 3298 3298 2183 2003 3626 3626 2003 166 3941 3941 166 3040 4981 4981 3040 558 2430 2430 558 1967 838 838 1967 1223 2591 2591 1223 4087 4772 4772 4087 1131 793 793 1131 4860 654 654 4860 4360 277 277 4360 3247 4...
output:
11219931
result:
ok single line: '11219931'
Test #64:
score: 10
Accepted
time: 6ms
memory: 43020kb
input:
5000 5039 3060 2327 2327 3060 274 1552 1552 274 3755 798 798 3755 3879 3771 3771 3879 4866 4510 4510 4866 4817 2258 2258 4817 476 1551 1551 476 244 2400 2400 244 63 1925 1925 63 3065 914 914 3065 1518 3120 3120 1518 1519 2331 2331 1519 986 3805 3805 986 3502 2281 2281 3502 1461 3322 3322 1461 4826 3...
output:
11489956
result:
ok single line: '11489956'
Test #65:
score: 10
Accepted
time: 5ms
memory: 43024kb
input:
5000 5059 1289 3595 3595 1289 903 2785 2785 903 4325 3784 3784 4325 1205 1050 1050 1205 4445 1939 1939 4445 3439 4675 4675 3439 2274 649 649 2274 4743 4819 4819 4743 2271 4124 4124 2271 1460 3694 3694 1460 3301 4457 4457 3301 439 2186 2186 439 33 4520 4520 33 655 3908 3908 655 3561 1367 1367 3561 41...
output:
11281728
result:
ok single line: '11281728'
Test #66:
score: 10
Accepted
time: 6ms
memory: 41188kb
input:
5000 5001 1389 3684 3550 72 4739 3223 376 4206 1434 4535 4156 161 3965 4942 2825 4337 1341 3105 4547 4364 3643 1487 409 4555 2803 4661 3539 3596 3798 1024 1317 4350 236 3350 4555 3367 3602 743 4988 603 4460 3252 4284 4478 4023 428 665 645 2732 2861 574 285 93 4853 2542 4032 4708 3187 4060 3860 2470 ...
output:
0
result:
ok single line: '0'
Test #67:
score: 10
Accepted
time: 5ms
memory: 41148kb
input:
5000 5002 3235 1045 94 3231 3671 1738 1902 4808 4575 1613 4477 4509 4555 687 4461 2839 2714 3999 1217 3042 4142 1430 3939 2440 2672 3704 3542 3108 294 4726 1497 226 1235 1283 1815 3947 4308 569 3427 2617 2662 1484 3858 2713 4666 3831 3456 3632 1415 4970 2345 2835 274 3048 4818 3855 1693 1787 157 475...
output:
0
result:
ok single line: '0'
Test #68:
score: 10
Accepted
time: 3ms
memory: 43228kb
input:
5000 5003 3979 3265 4841 3872 790 1542 1583 301 156 4346 3542 291 4179 2404 3399 694 4916 4774 2237 1867 2514 2091 791 2208 3138 2759 4053 2387 52 968 4999 2534 4939 2646 4948 1189 2661 1402 1825 2215 3971 3895 1792 4440 4339 1563 642 1521 4040 4494 1277 3551 3936 361 369 915 3377 1716 1665 127 3237...
output:
0
result:
ok single line: '0'
Subtask #9:
score: 38
Accepted
Test #69:
score: 38
Accepted
time: 850ms
memory: 149176kb
input:
1000000 1000003 262214 926745 374795 931193 376322 553203 654897 919964 302083 297509 94539 321091 762952 690322 298474 523830 364245 336003 511332 721566 583408 213476 926865 775434 638820 494468 860686 46698 955073 597209 698238 752663 449242 480634 872644 532745 299717 587299 189770 68703 474911 ...
output:
321387359630
result:
ok single line: '321387359630'
Test #70:
score: 38
Accepted
time: 865ms
memory: 148936kb
input:
1000000 1000200 538841 876624 844069 567281 521833 22062 963888 591528 32580 882288 848547 412509 149554 781918 42993 811602 559279 395158 255104 547487 660654 326602 528684 854897 187857 127104 330500 768455 393075 376721 341000 536820 712862 871914 363953 905056 690389 369998 758249 515335 620556 ...
output:
12559252846
result:
ok single line: '12559252846'
Test #71:
score: 38
Accepted
time: 620ms
memory: 168648kb
input:
1000000 2000000 801230 91684 106429 302266 745391 128578 179919 907953 298523 805173 76423 176000 845857 9671 204917 151494 778674 222856 48397 951716 457957 801802 542631 96319 735859 226405 600191 502144 201851 314549 299830 790803 220671 300055 210191 805547 934694 272816 261619 868604 151160 565...
output:
9999943
result:
ok single line: '9999943'
Test #72:
score: 38
Accepted
time: 863ms
memory: 149192kb
input:
1000000 1000006 918790 717554 358796 345560 231154 393958 637873 722774 912363 454726 432308 221216 131348 273979 761290 116864 345620 785104 527149 533285 333143 732854 777818 714400 89355 816898 952529 396904 962533 654954 616728 167190 146650 884876 436536 58601 461350 858472 930942 543108 772744...
output:
162139613915
result:
ok single line: '162139613915'
Test #73:
score: 38
Accepted
time: 860ms
memory: 146756kb
input:
1000000 1000400 630829 584609 297344 393544 554880 523165 447342 65903 373356 624284 874915 404050 937254 905555 507223 276727 511497 613815 500902 474727 454931 959108 948753 873328 122022 49465 116348 807713 871240 470874 967662 478608 449699 667437 227667 546328 499589 391165 909117 469075 872545...
output:
9156547886
result:
ok single line: '9156547886'
Test #74:
score: 38
Accepted
time: 617ms
memory: 168240kb
input:
1000000 2000000 917358 640529 886983 964448 870453 798843 176095 124645 232679 76651 336863 735744 421755 836104 175240 599411 26396 470414 446415 248661 778601 949580 650140 970702 82420 569318 918604 959709 883460 614419 819056 109586 338771 243487 269196 367443 993615 535595 816152 434523 367261 ...
output:
8999954
result:
ok single line: '8999954'
Test #75:
score: 38
Accepted
time: 853ms
memory: 149064kb
input:
1000000 1000009 799559 667148 85900 535734 342882 426201 363952 749776 265746 611943 737373 929852 275551 49123 256810 551114 326995 201501 318775 569195 50174 443721 628771 653366 572595 106624 11668 4005 2696 969596 343731 324821 844058 32223 967725 584458 847175 96940 480627 17512 103282 307853 9...
output:
142916545199
result:
ok single line: '142916545199'
Test #76:
score: 38
Accepted
time: 864ms
memory: 149212kb
input:
1000000 1000600 531328 484082 559130 411295 812119 281163 706604 507574 489940 366281 125475 204104 692251 739591 812669 900637 687907 865175 779404 369263 216504 591614 368822 891758 345786 4531 869492 103867 349405 532323 337427 420397 410728 206064 282870 444495 467574 188141 59985 422816 348727 ...
output:
7007112418
result:
ok single line: '7007112418'
Test #77:
score: 38
Accepted
time: 606ms
memory: 168760kb
input:
1000000 2000000 33486 222077 667537 818118 219706 277620 948078 308633 166834 380833 373110 295487 221845 438345 369755 80033 274119 974868 877137 512902 842350 905869 533457 812381 428981 655334 12825 576057 630476 881585 370986 587152 648358 219624 71305 737852 828345 765670 436094 159226 840258 5...
output:
7999964
result:
ok single line: '7999964'
Test #78:
score: 38
Accepted
time: 848ms
memory: 149076kb
input:
1000000 1000999 458459 172002 172002 458459 357145 706286 706286 357145 191668 79361 79361 191668 785795 556662 556662 785795 463776 39299 39299 463776 572902 213149 213149 572902 650492 221275 221275 650492 473426 248025 248025 473426 677866 839710 839710 677866 44250 872641 872641 44250 180175 721...
output:
456674403585
result:
ok single line: '456674403585'
Test #79:
score: 38
Accepted
time: 866ms
memory: 148868kb
input:
1000000 1001999 850645 767924 767924 850645 660801 271975 271975 660801 645660 978427 978427 645660 917338 685503 685503 917338 167086 646110 646110 167086 147355 573848 573848 147355 611593 481973 481973 611593 124636 740277 740277 124636 142210 196811 196811 142210 935436 704140 704140 935436 4544...
output:
472141310664
result:
ok single line: '472141310664'
Test #80:
score: 38
Accepted
time: 886ms
memory: 149036kb
input:
1000000 1002999 275535 363846 363846 275535 772970 903071 903071 772970 99653 134390 134390 99653 48882 814344 814344 48882 646204 477113 477113 646204 563023 677651 677651 563023 638102 485774 485774 638102 775845 232529 232529 775845 382362 586617 586617 382362 892030 502936 502936 892030 878000 4...
output:
454343593935
result:
ok single line: '454343593935'
Test #81:
score: 38
Accepted
time: 356ms
memory: 163312kb
input:
1000000 1000001 532561 552323 835095 858160 160652 312002 898761 370890 412135 496815 426218 224371 282318 815907 341175 992873 247504 717282 453484 73033 983986 243729 382443 313297 491778 4127 354594 454343 895480 304692 955483 268896 77227 260665 13793 941317 15004 315121 118386 541569 944745 672...
output:
0
result:
ok single line: '0'
Test #82:
score: 38
Accepted
time: 353ms
memory: 127784kb
input:
1000000 1000002 190608 145908 938300 263255 45227 156699 606369 275524 762575 704495 68853 947942 412127 270473 244504 766585 223774 269312 446695 614595 619023 814410 355969 564643 999313 255817 260998 367941 986759 181381 473914 186634 177362 308515 916791 439035 801167 749743 481289 631799 930935...
output:
0
result:
ok single line: '0'
Test #83:
score: 38
Accepted
time: 366ms
memory: 156136kb
input:
1000000 1000003 238685 136446 709576 479722 772611 933302 639287 609437 891510 142362 187269 324555 607535 250418 760494 832171 358075 666438 291214 683742 576329 8014 484867 450866 681227 282212 782931 309901 251165 484816 834668 861015 669485 859275 394436 73553 750228 785579 368250 934986 715584 ...
output:
0
result:
ok single line: '0'