QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353558 | #3050. Kuru Kuru Sushi | Kevin5307 | WA | 576ms | 7596kb | C++20 | 2.5kb | 2024-03-14 11:09:00 | 2024-03-14 11:09:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,q;
ll w[100100],psum[100100];
int s[100100],t[100100],fa[100100];
ll f[100100],g[100100];
inline int anc(int x)
{
while(fa[x]!=x) x=fa[x]=fa[fa[x]];
return x;
}
mt19937_64 rnd(20210448);
void _sort(vector<int> vec,vector<int> &sorted)
{
if(!vec.size()) return ;
int ind=rnd()%vec.size();
int x=vec[ind];
int a=min(s[x],t[x]),b=max(s[x],t[x]);
vector<int> v1,v2;
for(auto y:vec)
if(y!=x)
{
if(a<=s[y]&&s[y]<=b&&a<=t[y]&&t[y]<=b)
v1.push_back(y);
else
v2.push_back(y);
}
sort(v1.begin(),v1.end(),[&](int u,int v)
{
if(s[x]<t[x])
return pair<int,int>(s[u]-s[x],t[x]-t[u])>pair<int,int>(s[v]-s[x],t[x]-t[v]);
return pair<int,int>(t[u]-t[x],s[x]-s[u])>pair<int,int>(t[v]-t[x],s[x]-s[v]);
});
for(auto x:v1)
sorted.push_back(x);
sorted.push_back(x);
sort(v2.begin(),v2.end(),[&](int u,int v)
{
if(s[x]<t[x])
return pair<int,int>((s[x]-s[u]+n)%n,(t[u]-t[x]+n)%n)<pair<int,int>((s[x]-s[v]+n)%n,(t[v]-t[x]+n)%n);
return pair<int,int>((t[x]-t[u]+n)%n,(s[u]-s[x]+n)%n)<pair<int,int>((t[x]-t[v]+n)%n,(s[v]-s[x]+n)%n);
});
for(auto x:v2)
sorted.push_back(x);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++)
{
cin>>w[i];
psum[i]=psum[i-1]+w[i];
}
for(int i=1;i<=q;i++)
fa[i]=i;
for(int i=1;i<=q;i++)
cin>>s[i]>>t[i];
for(int i=1;i<=q;i++)
for(int j=i+1;j<=q;j++) if(j<=i+500)
{
int a=min(s[i],t[i]),b=max(s[i],t[i]);
if(((s[j]>a&&s[j]<b)^(t[j]>a&&t[j]<b))&&s[j]!=s[i]&&s[j]!=t[i]&&t[j]!=s[i]&&t[j]!=t[i])
fa[anc(i)]=anc(j);
else if((a>=max(s[j],t[j])||b<=min(s[j],t[j]))^(s[j]<t[j])^(s[i]<t[i]))
fa[anc(i)]=anc(j);
}
vector<int> vec,sorted;
for(int i=1;i<=q;i++)
if(fa[i]==i)
vec.push_back(i);
_sort(vec,sorted);
for(int i=1;i<=q;i++)
if(s[i]<t[i])
{
f[anc(i)]+=psum[t[i]]-psum[s[i]];
g[anc(i)]+=psum[n]-psum[t[i]]+psum[s[i]];
}
else
{
f[anc(i)]+=psum[n]-psum[s[i]]+psum[t[i]];
g[anc(i)]+=psum[s[i]]-psum[t[i]];
}
if(s[sorted[0]]<t[sorted[0]])
{
ll tot=0;
ll ans=0x3f3f3f3f3f3f3f3f;
for(auto x:sorted)
tot+=g[x];
ans=tot;
for(auto x:sorted)
{
tot+=f[x]-g[x];
ans=min(ans,tot);
}
cout<<ans<<endl;
}
else
{
ll tot=0;
ll ans=0x3f3f3f3f3f3f3f3f;
for(auto x:sorted)
tot+=f[x];
ans=tot;
for(auto x:sorted)
{
tot+=g[x]-f[x];
ans=min(ans,tot);
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 35ms
memory: 5716kb
input:
100000 13965 6828 987 32 151 5 44713 513 369 1934 1913 90374 4 336 286 4116 59505 8184 42405 84543 319 140 2888 6181 1 32 4535 39 1781 11 2 59002 12 1001 895 9 12 26 9497 15169 40 197 8 793 6915 40 47 10 35 3 106 3 3348 5 540 3269 439 402 1309 1165 71 91007 58683 944 11098 1976 5267 12974 170 2161 2...
output:
3010719821217
result:
ok single line: '3010719821217'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
4 4 1 1 1 1 0 1 0 3 2 3 3 0
output:
6
result:
ok single line: '6'
Test #3:
score: 0
Accepted
time: 134ms
memory: 7596kb
input:
100000 66336 384 935 2205 40262 8 70760 68 479 119 339 147 40344 2334 2 19936 62 1 1680 4 296 63976 60390 236 1 132 6104 9063 285 1 95 29 2 3 13723 3 67 45117 181 76 558 4075 405 15 76 578 265 78 5710 14 6577 2926 25300 1 88341 144 68741 1841 1 43533 1 84791 65657 3532 21 23820 1 1 88763 2 15185 149...
output:
14476170271395
result:
ok single line: '14476170271395'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
5 3 4 5 6 7 8 0 1 0 3 4 2
output:
32
result:
ok single line: '32'
Test #5:
score: 0
Accepted
time: 169ms
memory: 7272kb
input:
100000 65011 3557 48 7585 750 1 49 3 15 1 29662 622 529 7311 19615 107 3 6325 2 60 152 43 831 8 1 73 5 1803 42505 72 492 81261 436 1 10448 2721 18 146 24 337 45 30923 35586 6710 20223 4012 5251 33 273 23064 4867 23690 25261 149 10151 49 2248 2 10895 2 41564 1684 2 1041 326 2 1 1 4640 10 3 17 15 1489...
output:
14268480512454
result:
ok single line: '14268480512454'
Test #6:
score: 0
Accepted
time: 365ms
memory: 6024kb
input:
100000 74419 204 2 1 761 25 747 635 39850 1 5016 72325 6494 57474 217 7064 3103 3 152 16922 22 137 7328 580 184 5 299 5 1 6954 6023 171 1 11552 3680 11617 1338 4 1 18724 6024 91902 1 4 1 55087 46 1 368 67308 25582 24 10845 826 63398 58 1 80 6072 491 870 1100 114 6892 757 10 299 31651 304 916 2 30178...
output:
32413122740706
result:
ok single line: '32413122740706'
Test #7:
score: 0
Accepted
time: 102ms
memory: 5620kb
input:
100000 22508 1 32674 14 12812 5 2727 1194 13 312 26 12766 263 691 4 29 3 22052 4 81 304 223 4586 430 1 1 573 129 80942 976 22 50 18703 4 46 751 4 1 1952 105 1619 14 8764 3263 1 39311 3686 39813 396 15 56888 1 16882 29 6065 154 3 4007 4435 727 1693 31682 98 428 18840 27 42921 16145 1 45129 7 26 94214...
output:
9791309102399
result:
ok single line: '9791309102399'
Test #8:
score: 0
Accepted
time: 43ms
memory: 5540kb
input:
100000 8335 49 1107 2410 1 77312 18522 106 2 5 33 55827 10 18 577 8 9293 35 1 9181 3298 16 3 19 167 2033 61 51 55968 9 62490 4824 2008 49 1390 20 98547 28738 10 3 299 1 3 14314 61435 27226 1760 46 1 74428 275 60676 2148 98976 13436 50 109 1273 183 1125 38278 4876 9982 4 2 1 2638 2673 5 9 9 1 13 2 4 ...
output:
3587887985751
result:
ok single line: '3587887985751'
Test #9:
score: 0
Accepted
time: 93ms
memory: 5636kb
input:
100000 17257 13521 970 63 2 1 135 3723 6 16032 16051 2 942 11 4424 14 6044 1 16 32 2592 5 44462 229 78940 5 4 31151 8174 340 9 20952 25906 684 63403 2 92656 6 3590 54 17 168 3376 75241 1382 3 10 1238 2 84 909 7 919 2 4615 4760 2 2443 15649 432 4758 3 4 82153 162 20 1634 882 139 6 8 456 46 27 126 219...
output:
7483726371198
result:
ok single line: '7483726371198'
Test #10:
score: 0
Accepted
time: 265ms
memory: 5928kb
input:
100000 47239 4 248 33 5 74 105 11 8857 1491 444 3 1394 1950 954 126 24329 2260 7 5 52001 779 99 1 1 260 18 6 3 4192 7 1871 127 1647 2263 565 8503 126 17894 45 1 2 919 83 6 982 2041 7 73314 2 91650 7 512 1467 544 2 498 15 4084 65 515 4 101 10933 16 70 82460 91317 42 119 31114 3 2033 4305 1 23 2 186 4...
output:
20653706640379
result:
ok single line: '20653706640379'
Test #11:
score: 0
Accepted
time: 156ms
memory: 5512kb
input:
100000 26535 249 1 789 20643 12 182 40135 149 26886 1 18 27008 14590 664 2324 327 11397 455 23 13 1 1292 8 57 103 1 33 6 7 700 2525 38 74 4 1651 16 15 4006 28 18 893 2209 1270 19532 4 10581 567 5 25 34872 2 23 2 95 98 35159 1908 143 3 501 6 1177 374 2 32 24286 2732 396 3 6252 237 397 2352 24 4 10184...
output:
11372457240069
result:
ok single line: '11372457240069'
Test #12:
score: 0
Accepted
time: 291ms
memory: 5744kb
input:
100000 48770 50 4 74 60 30796 1125 7371 6646 360 32801 180 1245 74868 7712 34839 3252 25 10 989 29584 110 21853 113 59 51 33249 6 187 25857 4 92 8 211 1 3 1610 74922 149 39 21377 116 1 733 1167 15187 192 8788 4 2 721 81 23857 4 59 9413 902 50 18593 14295 9869 8 40 16914 1 3 408 1283 4408 68 2126 2 5...
output:
20861892772015
result:
ok single line: '20861892772015'
Test #13:
score: 0
Accepted
time: 156ms
memory: 5544kb
input:
100000 27812 95 2868 47419 1791 19637 280 768 1038 32728 2261 71 7555 464 18084 27340 14780 69 3210 1 408 14694 134 17154 176 223 11 4 628 10 3561 351 54821 157 18 32814 15120 58463 1 60 2 3 48901 436 15 6 94 13890 1192 25177 35 57049 4878 25529 15 180 35 120 361 15 31 342 2 265 2349 14 4448 596 29 ...
output:
12045208641346
result:
ok single line: '12045208641346'
Test #14:
score: 0
Accepted
time: 62ms
memory: 5324kb
input:
100000 10545 1667 658 3503 235 2 379 1 596 76364 1 40 1108 26 50 2507 1 87 702 63 18 6805 116 4 19191 4851 42216 22856 9920 487 2 359 62098 1146 17444 22731 19 6785 507 799 3517 76999 2 22 174 2 22 28 6 144 5 2576 1096 13280 15253 94 1 45858 53 4 2984 40625 168 4321 5673 100 2566 15966 972 45 64 232...
output:
4483464225710
result:
ok single line: '4483464225710'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
3 3 1 853 13773 2 1 0 1 2 0
output:
14627
result:
ok single line: '14627'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
4 2 4210 145 213 17870 1 3 3 0
output:
18228
result:
ok single line: '18228'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
4 3 2586 2 190 30047 1 0 1 2 0 1
output:
32827
result:
ok single line: '32827'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
6 1 60 1 53 33761 91 500 3 5
output:
614
result:
ok single line: '614'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
4 2 60 1 1835 500 0 2 3 0
output:
561
result:
ok single line: '561'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
3 1 641 29 241 1 2
output:
29
result:
ok single line: '29'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
3 2 4998 2647 6783 1 0 0 1
output:
14428
result:
ok single line: '14428'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
5 3 11 12180 49686 2 775 2 4 0 2 0 3
output:
64206
result:
ok single line: '64206'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
3 3 101 28 957 2 1 1 2 2 0
output:
1215
result:
ok single line: '1215'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
4 1 724 58208 688 101 2 1
output:
1513
result:
ok single line: '1513'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
3 1 101 38 6 0 2
output:
6
result:
ok single line: '6'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
4 1 161 9014 1 32 3 2
output:
1
result:
ok single line: '1'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
6 3 3039 1 2547 21 754 81859 3 5 1 5 4 2
output:
89751
result:
ok single line: '89751'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
4 2 1 13130 84258 85843 1 0 2 1
output:
13131
result:
ok single line: '13131'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
3 3 75073 80935 1 2 0 0 1 0 2
output:
231082
result:
ok single line: '231082'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
6 1 52334 4 4 98379 9 42 4 2
output:
52389
result:
ok single line: '52389'
Test #31:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
3 3 42 52334 9 0 1 2 1 0 2
output:
52385
result:
ok single line: '52385'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
6 1 3073 22 21 31 47108 1047 5 2
output:
4142
result:
ok single line: '4142'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 3 22 1047 3073 2 0 0 1 2 1
output:
4142
result:
ok single line: '4142'
Test #34:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
5 1 3663 1530 132 4228 5556 4 2
output:
4360
result:
ok single line: '4360'
Test #35:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
4 1 1530 206 4 4522 3 0
output:
1740
result:
ok single line: '1740'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
4 1 4522 4 3735 406 1 0
output:
4145
result:
ok single line: '4145'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
6 2 406 2 43 53 14500 184 4 3 5 4
output:
14553
result:
ok single line: '14553'
Test #38:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
6 3 34 2 1 1 20265 3836 0 4 4 2 3 1
output:
24106
result:
ok single line: '24106'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
4 1 52455 1 38 1227 0 2
output:
1265
result:
ok single line: '1265'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
6 3 8 346 18 1 5403 21 5 4 1 4 2 4
output:
778
result:
ok single line: '778'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
5 1 2626 134 720 567 5321 3 2
output:
720
result:
ok single line: '720'
Test #42:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
5 2 567 2678 8381 84632 720 4 1 3 2
output:
9668
result:
ok single line: '9668'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
5 3 16607 3518 3714 2 37551 1 0 3 4 0 1
output:
61394
result:
ok single line: '61394'
Test #44:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
6 1 615 16 5470 47683 32 84 1 4
output:
731
result:
ok single line: '731'
Test #45:
score: 0
Accepted
time: 205ms
memory: 4656kb
input:
40338 31475 2 19676 50 22259 100 232 59538 12 9 2283 4604 7995 14 36915 1421 1 5 109 3992 1 3 169 6041 7668 1170 5 206 40672 27017 18 55 5 34 14785 49 1 2 38 2 40 426 1 21 2 30 8389 2 1013 82540 51542 40631 38138 452 44855 1 2 298 3 435 70143 2614 3 72 7133 54963 84058 60624 74240 18 1676 176 3692 1...
output:
5484082203393
result:
ok single line: '5484082203393'
Test #46:
score: 0
Accepted
time: 216ms
memory: 4652kb
input:
23712 34077 1 7742 179 13202 4130 2473 37 18329 62922 107 7 5 1682 8311 27498 7 66 24988 2728 16 28 75 22 6 9233 1 1267 7 8 6756 30043 12 1 16 4 3 409 464 4689 15155 101 7789 28 2 13 247 56 4 2888 113 2251 3 163 91 29 36 1567 9 643 40472 24445 7158 8303 671 3426 4309 1 7572 2 19873 103 32 4 48703 83...
output:
3409274406868
result:
ok single line: '3409274406868'
Test #47:
score: 0
Accepted
time: 570ms
memory: 6160kb
input:
93356 87393 87983 6788 12709 20 1 24 237 78502 5179 75 65511 14718 22 73579 5 56 39 10198 76790 1 39 7 3 60 80 11533 44 16 2 5 799 2 7 18 26 12 26639 5127 685 43262 110 5 3043 2425 6518 52 5 5580 10 47 17782 26 9 600 1 37484 12 28 21 1 234 3955 8 2146 14292 31 95361 90 1 521 8988 44 6372 10 88336 8 ...
output:
35384364069102
result:
ok single line: '35384364069102'
Test #48:
score: 0
Accepted
time: 60ms
memory: 4256kb
input:
31528 9227 1411 79063 13128 899 3221 1074 12 3 1 24 1 13089 26 26 4225 275 22081 265 20 1 31 7 11 21744 3862 8 14 43211 90742 34642 6 27 4848 817 374 25 26 1 2 57059 15 7462 25866 675 10393 27 436 6054 6075 1886 1 18 12355 31 72 470 12522 4690 1413 2 21 6 8 24 10225 41675 26 11 53 16 117 72 450 3296...
output:
1259237588891
result:
ok single line: '1259237588891'
Test #49:
score: 0
Accepted
time: 576ms
memory: 5292kb
input:
22945 89103 32 2 70 16402 102 271 463 5736 25068 19319 31871 8225 95 299 7932 2250 13 11 1624 13164 3 340 3247 1363 123 1553 37 10597 60249 20 42 1354 255 80 5784 3519 14376 39752 7127 36477 1304 3 34 45851 28 561 955 374 36 265 74492 3417 14 3 446 1 20983 23 2 126 146 8 96734 1 1752 41756 6 1 2537 ...
output:
8859910385327
result:
ok single line: '8859910385327'
Test #50:
score: 0
Accepted
time: 493ms
memory: 4856kb
input:
19884 75907 4 7 56479 209 61705 778 1986 6548 2 3 981 2202 144 1 176 39 408 56 5 394 2 3 5558 589 11 22 13558 2599 8 95 149 4119 810 26 1609 1919 255 12 1 11 79392 8717 938 3936 60360 55 1 102 1453 3 31096 403 1293 3170 12 2 19015 3 112 5845 3773 670 14 1 2 31236 5736 1 46 22106 38 2988 59071 230 1 ...
output:
6594131353739
result:
ok single line: '6594131353739'
Test #51:
score: 0
Accepted
time: 402ms
memory: 5440kb
input:
67294 61764 5 1 1238 2 24237 8103 5 192 142 14449 13 5418 1710 564 510 4990 9 33075 4 193 40563 1 9696 162 3917 17625 63 69 88105 2 22 242 21567 1 196 3489 20 5527 1359 13 3 1988 24931 9550 26 96 1 93442 2402 9 164 483 2098 11 24619 133 1300 30 10 5670 18143 436 4 2981 13 1 77 3573 1545 66348 808 47...
output:
17799943576190
result:
ok single line: '17799943576190'
Test #52:
score: 0
Accepted
time: 451ms
memory: 4896kb
input:
17438 68751 767 5250 41962 3973 1 37202 1432 13830 91 12 1 63 73483 127 568 356 1523 10 2 5749 6364 11412 203 3563 8 8 4 17105 25 74 122 582 2 1646 53243 6433 1878 6172 5 10003 5130 4 23751 36401 7 65 3 10596 23 4 1 2397 3 12213 430 86 2057 78893 820 706 15166 13411 104 520 89137 4224 8 3305 45494 8...
output:
5187822506300
result:
ok single line: '5187822506300'
Test #53:
score: 0
Accepted
time: 355ms
memory: 4824kb
input:
37812 54561 1 695 319 337 161 352 2 124 2593 2 61 37978 22 15 34670 4425 94 160 324 131 23 8 10 10063 2812 62600 13 634 10462 2 341 57 590 21 4899 3 714 9296 62 18 34 1 2 88310 17 318 1709 16 10882 244 1528 6 137 8 20 51486 12843 951 5 37 73 26 1534 2739 34566 3 1 932 356 2188 13183 65354 149 8877 1...
output:
9063810670638
result:
ok single line: '9063810670638'
Test #54:
score: 0
Accepted
time: 433ms
memory: 4956kb
input:
37931 65403 546 386 46 66558 8 6 262 1 75 3406 639 26803 19 996 5 335 643 1163 37 115 838 4 90941 1806 22 5 93 38314 6 1238 6590 63 8 134 5608 9793 1082 3 5 63 62 22107 5320 1196 56689 1 3 18 75 44 13 970 20 4 7692 426 7616 98 184 9 50833 28351 34 5 24925 3 38090 168 9264 1642 52967 14110 10 6 31 7 ...
output:
10874844161103
result:
ok single line: '10874844161103'
Test #55:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
20 1 1592 33 379 186 213 56 49344 2350 425 8930 729 34707 18 3956 3889 8 19 98 86357 25487 3 1
output:
412
result:
ok single line: '412'
Test #56:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
20 1 213 56 49344 2350 425 8930 729 34707 18 3956 45731 3145 13 12 11137 55 4 2189 379 186 4 5
output:
425
result:
ok single line: '425'
Test #57:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
20 1 12 2343 130 170 30934 219 111 3361 2267 3194 4 52125 6342 25 1640 952 2502 11677 124 3 3 2
output:
130
result:
ok single line: '130'
Test #58:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
20 1 34562 261 32450 714 58171 187 3 35 1939 5266 1 8 21990 136 140 1338 17566 60 79 1 19 2
output:
34824
result:
ok single line: '34824'
Test #59:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
20 2 1 1 407 63121 30 36 96298 126 14 250 20 5884 3438 694 15236 1 9577 18 1 34917 8 7 15 14
output:
15362
result:
ok single line: '15362'
Test #60:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
20 3 503 2745 196 174 21270 56 1 87 96735 49 5 614 161 4104 31 2 91856 11116 4 16 11 9 17 18 16 19
output:
114146
result:
ok single line: '114146'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
20 1 15 1 2315 1377 6119 7 9 36 6509 1 13 43675 1 21 1 34518 10 1 34016 2671 0 1
output:
15
result:
ok single line: '15'
Test #62:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
20 1 757 7850 789 2593 8 207 2911 51954 9 51036 1 2315 1377 6119 7 9 36 6509 1 13 8 6
output:
54865
result:
ok single line: '54865'
Test #63:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
20 2 500 10 17 70576 2303 5260 207 2911 51954 9 51036 7355 448 74 491 2 35 496 648 318 18 1 18 2
output:
2942
result:
ok single line: '2942'
Test #64:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
20 2 11092 2712 282 79353 61628 1 412 446 99 5945 176 76353 2 1 1942 25431 2 4190 1 2769 7 8 12 11
output:
76799
result:
ok single line: '76799'
Test #65:
score: 0
Accepted
time: 275ms
memory: 5980kb
input:
100000 48976 97 6 13162 36976 63 2368 20 2052 1250 18511 2633 2 25 12 84 6311 3 1 45 1897 26 43248 1 12788 1 20 382 4443 1 756 102 434 7541 34 14230 418 103 2 3702 5 866 1446 12 13 12724 1 10870 330 22 17 84100 1 196 5 14 170 10 148 5061 25474 61 9 23122 8568 4839 2055 91 1736 1 3 1909 27524 31367 5...
output:
14297489612108
result:
ok single line: '14297489612108'
Test #66:
score: 0
Accepted
time: 526ms
memory: 6524kb
input:
100000 91987 182 67289 2508 3148 452 19 19 23034 405 89 5 395 18320 65295 2 3 1356 4 4893 889 58 143 16505 1 46372 91 51052 645 9965 10 94 1 912 17365 30658 43 5 7 64 1591 13 23068 32681 11219 3042 39813 353 107 19 296 544 1392 9210 63 217 35 205 216 538 2561 703 84689 5 1 22 57 131 535 8267 3 45950...
output:
26227706273367
result:
ok single line: '26227706273367'
Test #67:
score: 0
Accepted
time: 37ms
memory: 5220kb
input:
100000 6015 1222 19 23320 467 41581 451 1 10309 22 6702 2064 4093 576 422 2 3 525 14679 4924 86 4708 1 2 5 4101 797 2417 10 63828 1 37 37 23370 11076 14 15 2662 3818 235 3 189 5 2 83 88166 830 7296 25 2485 64 834 217 59 1 92 2638 13069 12593 1576 15856 131 1 182 62 93958 188 1 1 608 2172 43268 324 1...
output:
1760237733920
result:
ok single line: '1760237733920'
Test #68:
score: 0
Accepted
time: 540ms
memory: 6296kb
input:
100000 94690 11 30 2 26142 1906 5 34 2830 41072 847 41776 130 257 2 438 80932 49 250 61642 2447 3 49 13 381 10 2 55139 27 15735 498 47 7 6 5474 3 1351 148 2286 23 2 29234 17857 4 980 3093 2 31 18934 192 1 9851 145 22125 3344 638 22915 1 54 193 3845 37745 133 1 21 42000 1712 73 55995 2455 65 4311 45 ...
output:
27828324393224
result:
ok single line: '27828324393224'
Test #69:
score: 0
Accepted
time: 477ms
memory: 6108kb
input:
100000 77985 357 26514 4 1 3 183 15785 885 12803 6 16 30814 341 10162 403 2418 3 2393 60 5 5540 2 11 131 2 15006 13 2 7725 67451 39265 91578 6474 1 50 15 11795 40 13536 2 2 7535 56 1 12 975 63460 2195 2 40 45 22 994 75060 1482 1 9356 15856 3492 26 73956 18433 2922 3082 4336 93247 752 5 224 3 53302 3...
output:
22587919951252
result:
ok single line: '22587919951252'
Test #70:
score: 0
Accepted
time: 104ms
memory: 5464kb
input:
100000 22208 5 13 60 2298 4 3057 70 191 251 12 8062 5 99755 3 79741 5278 4 3 160 10 2470 24805 14613 57281 2 4368 52731 56 1797 25123 26 1926 1048 94 281 28136 43 5226 580 37 3 11454 4657 62 3 834 4028 735 90 84956 1 2 9 83310 35747 163 105 19 31110 85 2 308 6 63059 4 4 78792 60 545 5 46 3 373 2918 ...
output:
2573786833435
result:
ok single line: '2573786833435'
Test #71:
score: 0
Accepted
time: 426ms
memory: 6128kb
input:
100000 79366 825 11 1 4768 105 43 5 64 80 294 1406 86 6339 5570 9921 394 9 269 30302 10 46056 12823 404 268 803 6814 206 567 3 65528 2181 1 3719 30468 6089 142 73784 42 19149 21804 134 39337 2250 79526 220 2114 4 522 37869 15046 3198 5146 1964 712 29210 1488 60540 42 58641 12758 9114 26053 29043 21 ...
output:
9293289270604
result:
ok single line: '9293289270604'
Test #72:
score: 0
Accepted
time: 163ms
memory: 5552kb
input:
100000 34027 566 113 21674 5056 724 46439 4 3157 6 21 55 635 6 3 9 554 90105 2406 117 25 1837 46 20010 9720 217 1 1184 98 3 32417 56980 5640 41 35019 10034 1 2300 11 1 2 95 1813 1966 45 39683 33853 1603 11374 50162 9169 195 22515 43843 14 6 30 5130 2 177 9133 13 378 2 869 11 79184 2 32751 2021 456 1...
output:
5531801035809
result:
ok single line: '5531801035809'
Test #73:
score: 0
Accepted
time: 20ms
memory: 5240kb
input:
100000 3470 10574 6 7629 33653 55965 34764 4 5 5 158 603 736 5798 3 2 55122 267 697 216 853 1060 2979 5066 22412 5 6363 121 247 303 49313 13660 7 53642 90 1 4 49896 16 80430 10 82 6239 2 96 16 3 66 5 2835 67519 1681 85 2048 6 27 202 1 1844 74062 648 9 19251 1 524 26205 11 1 1066 2167 4 3854 3 1290 3...
output:
426786721583
result:
ok single line: '426786721583'
Test #74:
score: 0
Accepted
time: 330ms
memory: 5896kb
input:
100000 67829 2 102 3 36 25626 71784 3 52 17720 1 40 7942 3 38800 1 14296 160 391 11 205 123 1 89 31706 1803 58 2787 2753 2207 38 971 24805 22442 69628 18657 22547 37483 46 9530 267 2667 213 7 7 2 22116 2010 9209 21951 2249 496 651 1528 27654 20 5584 4658 39 1 1 71904 645 3 11214 30 39 59811 386 1863...
output:
6128766260863
result:
ok single line: '6128766260863'
Test #75:
score: 0
Accepted
time: 36ms
memory: 5292kb
input:
100000 7207 751 31540 7 8 184 18978 7109 25 15 24795 134 733 6 196 6212 231 51313 195 36062 1139 2896 1 34 219 85873 76163 41 20 3511 16995 20 13 19 1 2 1633 83768 1 10 147 11713 37805 23123 1 1 78 15926 948 1 11784 12273 64 5 3 161 8 103 4427 3 5 8856 74 3514 10 7 13814 39382 843 2266 8 112 2008 95...
output:
648316118615
result:
ok single line: '648316118615'
Test #76:
score: 0
Accepted
time: 122ms
memory: 5496kb
input:
100000 24794 65703 9324 792 1 15217 143 42950 735 956 1567 21 504 355 1869 866 15132 22913 42 2 31058 34 5 52 29 5475 18608 2 20 85264 49 6230 19391 1 94 21 5 399 83124 108 526 11652 1212 258 68 44906 9274 19915 12196 201 4281 2 3127 5980 3 135 28 87916 11195 14457 39920 1 14273 4 21758 7 2 8587 224...
output:
1856955856781
result:
ok single line: '1856955856781'
Test #77:
score: 0
Accepted
time: 276ms
memory: 6052kb
input:
100000 55838 7 6777 940 38890 612 896 25306 85 6291 9748 1 1344 30 29 2 164 1133 4701 466 9374 51793 9180 1 34174 9 11497 4611 6 10417 1 421 33977 18 4806 45006 357 71 200 3 8432 6002 354 2 15347 41147 33 3659 17 59 15 26 109 41945 71147 847 2 28 74 867 9 135 303 6 34222 9357 14 3 6 172 54 6271 4622...
output:
4767169855497
result:
ok single line: '4767169855497'
Test #78:
score: 0
Accepted
time: 121ms
memory: 5424kb
input:
100000 27771 59318 3893 1 23 2807 90636 36 9088 2560 1 17 2989 86 4 89 15012 101 1 69 17805 25435 6 151 6 11 11 9146 332 34637 85 432 2558 32 18093 1 4325 54279 32350 3 11560 987 78 1918 49348 1 146 32 10981 314 81651 1902 383 41926 1 45813 26 2550 60 1 54 99156 1 2 2 6679 1793 944 34796 2017 1 9 37...
output:
1845325500334
result:
ok single line: '1845325500334'
Test #79:
score: 0
Accepted
time: 56ms
memory: 5544kb
input:
100000 10055 4709 19 68881 226 297 38 33 491 20 9922 2587 256 2067 511 14 80368 64 940 3 799 67 3 697 58869 7379 3620 16485 8 31 61 896 6257 39290 31641 70 17 68 2 24167 2245 1277 6164 21264 59 1 1120 30335 3 55 31145 395 149 1 94049 3892 1 1014 18025 3506 202 67 2141 5069 661 18 87 12442 1 1036 41 ...
output:
902807393669
result:
ok single line: '902807393669'
Test #80:
score: 0
Accepted
time: 359ms
memory: 6324kb
input:
100000 80723 705 1 61672 92133 160 886 68448 7746 13 1 33 8 9 657 86541 1 12 2 2118 47610 112 627 32 53 56 153 9424 1 55 143 67935 132 26270 2108 34 1 65692 138 746 6 7 37853 35 32706 1 15049 27805 12666 22709 13673 1558 22777 11705 4 819 38922 183 1481 8157 108 40691 51 1056 20 1 16850 30589 2977 1...
output:
4652843960607
result:
ok single line: '4652843960607'
Test #81:
score: 0
Accepted
time: 170ms
memory: 6140kb
input:
100000 37560 144 45 27787 60407 33767 58087 270 271 17170 31249 153 12291 22 697 1579 2247 50 32 3919 1157 757 18023 45 21887 254 99 12 181 2554 11 29252 1493 359 44 40 295 15299 284 1107 4 7699 55 1 10 84009 2865 1047 26360 1856 834 1 14 2098 1411 1693 4959 24099 16 2 10 2 246 1355 145 28 6094 3855...
output:
1992330686854
result:
ok single line: '1992330686854'
Test #82:
score: 0
Accepted
time: 136ms
memory: 5584kb
input:
100000 30538 173 6878 2 1 374 1256 92391 70624 1 1715 32 463 71527 59 17 6732 32125 964 16148 8827 5 92681 8 15372 82 78740 3115 214 2 23706 541 410 67826 1 399 725 452 2277 21564 18998 2510 3 9 64967 708 7014 35 1 84050 180 8402 6784 10 539 59474 1 6298 14814 66933 584 4 12629 29 367 26 5259 124 69...
output:
1292762855449
result:
ok single line: '1292762855449'
Test #83:
score: 0
Accepted
time: 245ms
memory: 5832kb
input:
100000 58012 5919 74943 3419 2641 64495 6 76975 42582 3 22043 99013 736 3 15296 1 2 3 7342 74 52 37845 2789 672 1892 8465 22 366 11144 2 2 285 8872 56045 23923 4 134 6878 19 63 21 5744 453 47 51 3 95 2776 1044 25608 46 33 515 310 27 8 12448 37823 32331 2160 3 25306 1 131 6 572 8781 1200 63 24342 945...
output:
3350820284389
result:
ok single line: '3350820284389'
Test #84:
score: 0
Accepted
time: 207ms
memory: 5664kb
input:
100000 43497 7 2545 21295 394 2761 313 12 1673 91390 19 6517 171 221 2 8 7330 15 3821 1725 1844 24107 1222 10740 3655 1150 227 685 82 1140 82 11416 66287 31867 731 35 3311 16 1 426 197 2607 13327 80457 33397 59 5 109 774 36338 5 57 806 315 2 51037 626 6800 964 871 4 49924 13 11 93934 30245 3 30 1749...
output:
1907519852472
result:
ok single line: '1907519852472'
Test #85:
score: 0
Accepted
time: 268ms
memory: 5876kb
input:
100000 57777 24 1399 5 2 404 6 71 2 31 3246 15 14297 642 15 13581 143 2949 4 121 4851 15603 37535 74 109 228 6 13 3 5761 288 859 4 176 4023 15 44 7053 1057 2 94 6095 4097 305 434 13471 47 16 4 2678 95429 17 60297 6048 382 4872 2 2 1 15 740 24257 6654 88 431 13 55724 54071 4 507 107 11 7095 397 5868 ...
output:
2340226923448
result:
ok single line: '2340226923448'
Test #86:
score: 0
Accepted
time: 288ms
memory: 5876kb
input:
100000 61912 81 2395 1 1 8 1013 20 42 5 45241 4654 2284 2 8394 333 107 14 78747 1 24 476 6 33 7 5 20931 14604 56559 2128 2 13 23 6336 65583 3 1 45 7610 280 967 330 4500 1 1 10825 11173 819 64 12093 103 62731 11151 1 7062 2901 993 10383 23 19536 2 4 41698 4053 4735 4462 15447 25 3166 879 50301 2 605 ...
output:
2732578925041
result:
ok single line: '2732578925041'
Test #87:
score: 0
Accepted
time: 3ms
memory: 5396kb
input:
100000 317 6 844 1771 4644 14449 263 18104 11 14 66188 8 9971 11 3 147 30 62675 8 756 4948 2 2574 3 88 211 12039 696 13 5 292 1 1 1228 1292 136 38108 26055 1 182 1 3 3740 2 1 25804 10 90298 190 20 3 1 1552 138 9886 17 16 136 6 104 1 4335 30241 4 11 19 12 11467 1142 2 5 36 1318 3 3 18248 28 1124 1 10...
output:
25177696068
result:
ok single line: '25177696068'
Test #88:
score: 0
Accepted
time: 338ms
memory: 5968kb
input:
100000 73996 714 2435 1 15 64666 1 334 35651 16803 125 512 6205 1 126 1 8 98045 38 2 3818 24 4 37 55358 9 9 289 48 3 454 29 7724 1487 551 2 52501 2 394 187 97785 15 67 1179 14 6 44 1 32867 476 39690 15684 144 20 72 23814 1461 20 1238 26397 189 2 1452 61274 2224 737 2063 155 1 24850 296 82775 340 77 ...
output:
3647308774109
result:
ok single line: '3647308774109'
Test #89:
score: 0
Accepted
time: 300ms
memory: 5944kb
input:
100000 65323 1972 19879 14657 189 275 1177 111 1 1029 6 1 28852 1719 33 9406 15661 102 32 6674 4776 687 8 9203 417 11 56 5 787 1574 342 1042 17311 23 20002 32744 2 14 1 674 5402 168 3 15 7705 158 8 706 1282 4 1 5419 34764 1542 2 1157 63 219 7536 13 11 75727 2 49 13 52 2 14 2 2043 2 3 31503 2 1255 89...
output:
2885298851751
result:
ok single line: '2885298851751'
Test #90:
score: 0
Accepted
time: 518ms
memory: 6296kb
input:
100000 91353 88 22 174 24199 3 11814 1386 53 12263 4482 12208 67701 107 46 5 1656 1 3 85 2583 19845 5307 3 1 1 559 2 525 1 3493 406 24736 1 17 6531 2 2 46956 7031 7421 1 3897 63 87 1 118 9430 713 17 18 16382 5 42 116 7607 58 87010 15959 32 7342 8 182 46 17836 223 2865 49 10996 10408 8157 609 31049 8...
output:
26483948828100
result:
ok single line: '26483948828100'
Test #91:
score: 0
Accepted
time: 232ms
memory: 5632kb
input:
100000 40800 3 42 151 44279 1126 55 90 396 65 38 96 572 45803 3224 104 101 745 5687 144 576 4842 67 24320 8508 308 25169 24497 1186 3 68199 36 5 4168 16 29424 1 170 19466 13911 3 12 2 3165 1 12 6177 2433 25 101 329 2774 10165 6523 2 22353 53 21276 1 3143 39485 53295 6 5380 22 9298 3341 19 80697 222 ...
output:
11915484669107
result:
ok single line: '11915484669107'
Test #92:
score: 0
Accepted
time: 149ms
memory: 5672kb
input:
100000 25630 162 1738 1395 26727 13 766 3 4335 81113 18 10104 24 41 1878 2617 23 25020 11 394 1740 8 1 32249 283 4758 58 893 7303 1341 43 244 83 327 394 557 67572 915 11 6141 58 1 3677 3 1 1491 1078 88 1848 4977 400 3719 1 9617 95647 3877 24 7 12225 2391 273 197 35 22317 798 37 14564 13755 38 14578 ...
output:
7545261434951
result:
ok single line: '7545261434951'
Test #93:
score: 0
Accepted
time: 132ms
memory: 5516kb
input:
100000 23399 495 2 13373 84303 11 2621 558 369 6782 110 26 187 31209 102 291 46 1 72 11053 781 44 194 10 1 647 6 1933 1 214 417 54 9167 107 37 166 6143 223 47 71 8104 45 44 95366 36 685 15060 2162 2797 27765 100 232 32 1842 13348 169 1085 2 5713 65 43 149 361 2787 7308 39 23752 38327 88724 1 3 5875 ...
output:
6753772437932
result:
ok single line: '6753772437932'
Test #94:
score: 0
Accepted
time: 229ms
memory: 5628kb
input:
100000 40417 537 42 243 2 121 799 476 826 526 14060 8835 75 13 24 2284 9006 221 9 35072 3 2 14 99029 153 2106 42183 6469 2274 3 308 26 3266 17443 4149 1362 30 77 47084 37048 19058 68377 2 11917 71693 23 27495 2 15577 1 53 2 1018 225 4087 1941 94987 20 16 34 35008 17082 26023 3472 7435 226 235 19 175...
output:
11768718067586
result:
ok single line: '11768718067586'
Test #95:
score: 0
Accepted
time: 484ms
memory: 6352kb
input:
100000 96673 36391 106 1338 1123 1722 41 3 30 2 18 49 1292 14324 222 958 38198 12 141 2 84316 3575 628 623 18854 68 7 3 53385 5969 709 247 54792 19 11733 32231 6 49628 9 6 56 3 99 594 6 50 79 45646 17 2 23 1 648 14882 4 74275 99 1 14249 2 74 224 6873 3151 44 73018 2004 366 21 3056 908 580 211 4080 3...
output:
13791596864783
result:
ok single line: '13791596864783'
Test #96:
score: 0
Accepted
time: 14ms
memory: 5236kb
input:
100000 2211 351 6438 4923 9 58203 419 2 47281 76 2320 22626 244 820 35 1 26813 66 3251 102 39888 201 3055 30 27 272 262 20 10039 11485 201 115 1004 42 1 1699 4336 645 5942 5 24 38051 795 6383 1658 19906 240 931 548 48 1 6 4524 9973 3523 4 1 4 278 2 45866 10 9462 633 69829 14933 5443 66519 64603 1 93...
output:
255633391034
result:
ok single line: '255633391034'
Test #97:
score: 0
Accepted
time: 178ms
memory: 5864kb
input:
100000 37184 1321 1 48569 14607 8470 22 7159 1 5 96 496 79223 650 1 7 195 430 2 164 8 3 12 147 5807 1087 147 643 5112 2420 872 93 40 3 9253 3 1638 79 30 708 2257 678 3 3366 23 3 2823 29468 7 157 3632 5 27 74 2 9806 21 1 4 3689 4 8 644 13380 1496 10 31 90 19 35175 60 13728 7 61 310 55945 257 17799 49...
output:
4967016455448
result:
ok single line: '4967016455448'
Test #98:
score: 0
Accepted
time: 285ms
memory: 5896kb
input:
100000 63331 58009 14230 4 24 493 97549 1 8981 41 7 6122 1 1936 115 7210 1372 321 1 33 87068 439 13865 800 506 2 170 2160 48 14036 24741 226 1673 5452 7 22 322 3335 165 14993 1 202 93 885 14409 50223 67361 3 12 3 15 110 2 29 33025 856 47 98925 6 654 23434 3 1886 7 5 43 15018 64386 10796 971 13132 25...
output:
6553267029884
result:
ok single line: '6553267029884'
Test #99:
score: -100
Wrong Answer
time: 378ms
memory: 5944kb
input:
100000 66392 18 4575 21961 131 86 12968 228 106 1033 10126 96 14518 2 624 1 1 71243 1365 1583 21655 32 78 49 122 15 743 99444 71 1 404 70135 272 18 37173 1855 431 24644 4 2 11945 9581 11 11921 88 4032 7134 1095 41 235 13553 30 318 2 19752 788 1140 196 4566 121 879 27739 7 677 19867 44936 3043 16 248...
output:
15782824081507
result:
wrong answer 1st lines differ - expected: '15782202866773', found: '15782824081507'