QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#878364#8478. Count the OrderskangkunmaTL 379ms70116kbPython3301b2025-02-01 14:58:362025-02-01 14:58:36

Judging History

This is the latest submission verdict.

  • [2025-02-01 14:58:36]
  • Judged
  • Verdict: TL
  • Time: 379ms
  • Memory: 70116kb
  • [2025-02-01 14:58:36]
  • Submitted

answer

f=[1];M=10**9+7;n=int(input());A=0
for i in range(1000001):f+=[f[-1]*(i+1)%M]
c=f[n]*pow(f[n-1-(n%2)],-1,M)*f[n//2-1]*f[n//2]%M
l=[*map(int,input().split())];l.sort()
r=[[i//2+1,n-i//2][i%2] for i in range(n)]
for i in range(n-1):A+=(l[r[i]-1]-l[r[i+1]-1])*[-1,1][i%2]
print(A+l[r[-1]-1]-l[0],c)

詳細信息

Test #1:

score: 100
Accepted
time: 216ms
memory: 48128kb

input:

3
1 2 3

output:

4 6

result:

ok 2 number(s): "4 6"

Test #2:

score: 0
Accepted
time: 215ms
memory: 48128kb

input:

4
2 4 8 16

output:

36 8

result:

ok 2 number(s): "36 8"

Test #3:

score: 0
Accepted
time: 213ms
memory: 48128kb

input:

3
5 4 0

output:

10 6

result:

ok 2 number(s): "10 6"

Test #4:

score: 0
Accepted
time: 209ms
memory: 48256kb

input:

5
10 8 6 4 9

output:

18 40

result:

ok 2 number(s): "18 40"

Test #5:

score: 0
Accepted
time: 211ms
memory: 48384kb

input:

2376
732066934 787542711 613501093 852473623 294446565 348122408 985289328 167507061 806658388 511121222 341853121 153515566 820156407 742092647 113223691 901598965 606847836 755274866 370445420 672512540 744829773 947466591 988254594 283996337 807278550 917042422 344327102 74159600 245925457 536756...

output:

1206878118958 227684311

result:

ok 2 number(s): "1206878118958 227684311"

Test #6:

score: 0
Accepted
time: 222ms
memory: 48384kb

input:

2377
935443973 282098110 209733886 994373215 912009508 876448128 794342915 637565822 984754099 595493904 205732238 973706007 854823592 591159508 506469482 156715511 435918789 201563114 304957195 408581821 274822218 989898695 270185305 109848364 368694635 958374896 162548084 343715789 815972256 63271...

output:

1172332713482 205603460

result:

ok 2 number(s): "1172332713482 205603460"

Test #7:

score: 0
Accepted
time: 216ms
memory: 48896kb

input:

8099
284731 400001 410350 591342 466151 982943 577756 127675 456050 248864 655241 701130 295551 153378 382573 448292 309384 119566 722747 698777 170131 296900 909362 662800 900549 272225 863670 557073 880109 615108 710467 175261 439958 615173 14262 563143 155779 911214 804822 56855 610827 604616 889...

output:

3997895838 950346386

result:

ok 2 number(s): "3997895838 950346386"

Test #8:

score: 0
Accepted
time: 223ms
memory: 48896kb

input:

8100
342844 622626 352193 612128 821195 978850 273042 709888 133046 968791 680954 122753 217230 793728 990436 60018 586075 659219 331060 845883 165053 26041 138436 735701 887259 440588 576223 193024 944758 381242 947197 418428 917120 833672 855776 686407 197479 98244 720120 616770 133695 305009 1390...

output:

3968639332 714839769

result:

ok 2 number(s): "3968639332 714839769"

Test #9:

score: 0
Accepted
time: 277ms
memory: 55660kb

input:

70000
517299912 781627191 277315750 154595966 705349441 157372384 742980103 973597394 724221526 286427220 902709358 535847733 913715560 635964309 526703281 258086995 726404338 991571511 522980315 975919435 682049977 633907155 158094409 430377285 106192659 911537112 617116386 915970341 675539766 7244...

output:

31433068564330 251682640

result:

ok 2 number(s): "31433068564330 251682640"

Test #10:

score: 0
Accepted
time: 259ms
memory: 55816kb

input:

70001
933908512 332481434 277587672 209990853 243123141 548498376 917704381 283009230 846466804 861207469 991069319 473411889 778332214 450366950 220818685 273687639 310771401 160889850 121544026 389317160 728698838 950642363 478297068 834555683 406488062 926057398 839599151 616643957 187485457 6462...

output:

31554480244590 36359314

result:

ok 2 number(s): "31554480244590 36359314"

Test #11:

score: 0
Accepted
time: 379ms
memory: 70004kb

input:

200001
218216268 190626852 879553956 919180462 337088089 408821918 567907115 710620605 692800304 761529778 851982084 563343220 782647938 713887404 543533549 565581548 425006358 257037083 185164137 919030279 768301007 247468599 616256184 206490667 949837207 216042172 607839745 957950610 623089023 985...

output:

89966512736670 224781302

result:

ok 2 number(s): "89966512736670 224781302"

Test #12:

score: 0
Accepted
time: 374ms
memory: 70116kb

input:

200002
928240202 436448387 879825877 681160016 979894499 104980619 947664103 803382357 815045581 641342735 245374753 999355417 852297301 323257336 149266328 874597526 214406130 121322713 683727848 244045379 609917160 769236517 936458842 112221023 350132609 142179834 536907177 658624226 135034713 702...

output:

90101732731778 116138171

result:

ok 2 number(s): "90101732731778 116138171"

Test #13:

score: -100
Time Limit Exceeded

input:

953547
1451866 842217196 890450923 285774195 693778568 182073139 430811616 563014436 946088298 331891428 479538820 350527184 261377935 874616760 99150192 825085544 799089973 248726848 663075263 445481090 11450166 13331555 809049505 221143016 164336514 680827572 62017374 961446558 215120832 577504413...

output:

476348290385774 235960272

result: