QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#139645 | #5405. 爬楼梯 | 1kri# | 5 | 54ms | 3956kb | C++14 | 822b | 2023-08-14 08:52:00 | 2024-07-04 01:41:39 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
int n,m;
int a[200005];
int l,r;
int len,c[200005];
ll work(){
ll ans=0;
sort(c+1,c+1+len);
if (len&1){
int mid=(len+1)/2;
for (int i=mid;i<=len;i++)ans+=2*c[i];
for (int i=1;i<mid;i++)ans-=2*c[i];
ans-=min(c[mid]+c[mid+1],3*c[mid]-c[mid-1]);
}
else{
int mid=len/2;
for (int i=mid+1;i<=len;i++)ans+=2*c[i];
for (int i=1;i<=mid;i++)ans-=2*c[i];
ans-=c[mid+1];
ans+=c[mid];
}
return ans;
}
int main(){
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)scanf("%d",&a[i]);
while(m--){
scanf("%d%d",&l,&r);
len=0;
for (int i=l;i<=r;i++)c[++len]=a[i];
sort(c+1,c+1+len);
ll ans=0;
ans+=work();
printf("%lld\n",ans);
}
return 0;
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3824kb
input:
10 10 323351358 540774025 513831404 171513818 162079008 234580967 887182642 765979034 329924749 677555871 2 4 1 6 8 10 2 5 1 9 4 6 9 10 2 10 1 8 8 10
output:
711577793 1530795597 783685407 1099707620 3625910517 135569108 347631122 3919843439 3442003862 783685407
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
10 10 356685563 915148434 563845435 480227923 510014130 571548808 489307692 666691543 573877683 800166552 5 8 1 4 1 10 3 10 1 7 3 8 5 8 5 6 5 6 2 4
output:
416302380 1200543254 2247001181 1130075439 1427936560 591240777 416302380 61534678 61534678 786223510
result:
ok 10 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
10 10 259041296 18437783 835927251 200068667 931291913 220668768 841571584 64630364 869262858 448307535 5 10 4 9 4 9 3 10 8 10 4 6 2 5 2 4 1 4 3 8
output:
3423775327 3692614296 3692614296 4701136828 1225587817 1441846391 2461566844 1453348052 1693951565 3631587415
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
10 10 694546061 683750732 282826928 44704999 202358913 413195054 57606354 882383775 603016817 756343723 3 10 1 9 2 10 6 8 3 5 5 7 1 8 1 7 4 6 1 4
output:
4004516224 4422032256 4545627580 1293966142 395775843 566424841 4042388730 2893175147 579326196 1700605928
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
10 10 75522620 489110151 476088987 919220128 114109105 664499311 296664800 117714384 936389932 742669420 5 10 1 10 4 10 1 2 3 9 2 4 1 6 6 8 2 4 5 6
output:
3262306237 5330556928 4061412273 413587531 3803817977 873241118 2801196592 914619438 873241118 550390206
result:
ok 10 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
10 10 708842660 535631736 313983181 60960887 709239973 805842351 640508065 995203777 786390356 570768327 5 7 7 9 7 10 7 9 2 8 6 8 4 10 8 10 5 6 3 5
output:
261936664 563509133 994753191 563509133 3130688686 544057138 2561666502 640057479 96602378 1043535878
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
10 10 949140873 817668912 216488537 181549618 394932991 526353574 808587752 448239013 817070969 296679334 6 10 2 8 2 7 1 8 6 10 3 6 5 8 2 3 4 10 2 7
output:
1683366187 2665972162 2587857601 3642967343 1683366187 868052366 905424083 601180375 2504394682 2587857601
result:
ok 10 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
10 10 216976438 311196676 362414991 166779537 394400237 257402421 7949303 795846086 161382188 190830847 4 8 6 9 6 9 4 7 3 9 1 7 4 9 2 7 7 10 4 8
output:
1940412082 1671813799 1671813799 863524752 2342477688 1312187269 2132452548 1217967031 1605242225 1940412082
result:
ok 10 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10 10 168117094 215701804 648251116 480535594 268077263 814190009 150894926 29759319 963450984 384460880 6 8 1 7 2 8 2 9 1 3 3 4 3 8 6 8 4 10 2 4
output:
1447725773 2764150331 3040865881 4271530451 912683334 167715522 2776032091 1447725773 3522815444 697383102
result:
ok 10 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
10 10 16571107 681078796 450724252 846525392 447473866 502898147 991995131 660439261 933193062 456232325 4 7 4 9 1 6 1 8 3 5 2 3 7 9 2 7 3 10 5 7
output:
1432669775 2135718491 2179292325 3367201302 794852666 230354544 604309671 2058825459 2992107398 1033618249
result:
ok 10 numbers
Subtask #2:
score: 0
Time Limit Exceeded
Test #11:
score: 0
Time Limit Exceeded
input:
200000 200000 1 2 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 1 1 1 2 2 2 1 1 2 2 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 1 2 2 1 1 2 1 1 1 2 1 1 2 1 2 1 1 1 2 1 2 2 2 2 1 2 2 1 1 2 2 1 2 2 1 1 1 1 2 2 2 1 1 1 1 1 2 2 1 1 1 1 2 1 2 1 2 2 2 2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 1 ...
output:
17766 92870 56732 16462 79590 3872 79674 3370 151158 52672 41424 27644 52872 33690 47896 76136 59296 75972 113274 89092 114330 48490 24112 6810 164898 10914 9738 3316 33638 1510 16344 10722 89260 87924 12710 11498 464 61810 9336 100798 59812 170450 7374 78296 10230 173826 56696 106278 7504 141524 52...
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #31:
score: 25
Accepted
time: 51ms
memory: 3956kb
input:
2000 2000 934094958 536783701 145230662 389097466 662916743 15680595 497269445 277327696 295204335 399565879 103085285 660476806 406097164 491009942 123591789 940451006 657478375 690285007 370217804 34759017 896304691 785120106 102507838 814135240 179075942 374826926 706283825 750182730 494056277 17...
output:
273757423642 66476977112 237905924503 268145773779 1009274567874 133235037708 490463511544 488261294368 281356752080 752867613163 140878891959 116280565475 431247126230 47187175834 623046882965 168840754351 84041149197 380784864121 163937321134 258535804412 446360806108 98427472953 348024159178 9069...
result:
ok 2000 numbers
Test #32:
score: -25
Wrong Answer
time: 54ms
memory: 3920kb
input:
2000 2000 430676823 601313211 831915691 571317219 725924558 359178143 624054422 334329457 97735569 856155674 622583253 647480072 233495215 952504395 933848132 946405571 119999572 531138207 563350953 468019888 525396948 259152810 547609710 173524832 37300825 977998768 298207574 937208131 54221721 646...
output:
572256829943 664805649055 156946619190 609964613731 133184514146 27573811698 176175454437 480273237819 15693149570 496044812586 339601590747 60339154451 402831452507 396565742189 145255610947 684304273826 529869367988 569576214542 364096388216 239357736074 76777255979 141189744624 104700932792 29812...
result:
wrong answer 1300th numbers differ - expected: '1473089758', found: '5160924417'
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%