ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140781 | #704. 第K小的数 | Kogenta | 35 | 3ms | 1200kb | C++ | 765b | 2021-10-19 11:15:24 | 2021-10-19 11:15:25 |
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int l1,l2,r1,r2,k;
cin>>l1>>l2>>r1>>r2>>k;
if(l1>l2){
swap(l1,l2);
swap(r1,r2);
}
if(l1<=l2&&r1>=r2){
int now=l2-l1,now2=r2-l2;
if(k<=now)cout<<l1+k-1<<endl;
else if(k<=now+now2*2){
k-=now;
if(k%2==0){
k/=2;
}
else k=k/2+1;
cout<<l2+k-1<<endl;
}
else{
k-=now+now2*2;
cout<<r2+k-1<<endl;
}
}
else if(r1>l2){
int now=l2-l1,now2=r1-l2;
if(k<=now)cout<<l1+k-1<<endl;
else if(k<=now+now2*2){
k-=now;
k/=2;
cout<<l2+k-1<<endl;
}
else{
k-=now+now2*2;
cout<<r2+k-1<<endl;
}
}
else{
if(k<r1-l1+1){
cout<<l1+k-1<<endl;
}
else{
k-=r1-l1+1;
cout<<l2+k-1<<endl;
}
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
8886 6221 78097 91055 74492
output:
44799
result:
ok single line: '44799'
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 1196kb
input:
8485 4137 10391 92418 17568
output:
19798
result:
wrong answer 1st lines differ - expected: '19797', found: '19798'
Test #3:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
8971 10295 71065 64956 44009
output:
31637
result:
ok single line: '31637'
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
10684 8717 80822 67687 3240
output:
11319
result:
wrong answer 1st lines differ - expected: '11320', found: '11319'
Test #5:
score: 5
Accepted
time: 0ms
memory: 1200kb
input:
3958 1898 85945 51639 18644
output:
12249
result:
ok single line: '12249'
Test #6:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
1793 1883 56708 52929 67645
output:
35660
result:
ok single line: '35660'
Test #7:
score: 5
Accepted
time: 0ms
memory: 1200kb
input:
9170 6442 44565277 52007711 60198538
output:
30107074
result:
ok single line: '30107074'
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
6503 4398 42576185 41246506 39953330
output:
19982114
result:
wrong answer 1st lines differ - expected: '19982115', found: '19982114'
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
8810 1858 83829062 7992207 44881061
output:
112736376
result:
wrong answer 1st lines differ - expected: '36899520', found: '112736376'
Test #10:
score: 5
Accepted
time: 0ms
memory: 1200kb
input:
2043 5959 76809751 61209845 80275334
output:
40141667
result:
ok single line: '40141667'
Test #11:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
3545 10083 89218900 13553199 23421584
output:
11717605
result:
ok single line: '11717605'
Test #12:
score: 0
Wrong Answer
time: 1ms
memory: 1196kb
input:
9475 3919 29090865 62401189 66501333
output:
37423861
result:
wrong answer 1st lines differ - expected: '37423860', found: '37423861'
Test #13:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
10852 1890 62828646567693 870312128990889 105911095951062
output:
12740
result:
wrong answer 1st lines differ - expected: '52955547981901', found: '12740'
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
2752 6137 841041922084030 428187075059640 226616769271876
output:
2751
result:
wrong answer 1st lines differ - expected: '113308384640382', found: '2751'
Test #15:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
5351 7789 956375681249281 133146269380995 871031626016150
output:
5350
result:
wrong answer 1st lines differ - expected: '737885356648293', found: '5350'
Test #16:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
1456 8032 419885911205932 252590350792861 422791002642414
output:
1455
result:
wrong answer 1st lines differ - expected: '211395501325950', found: '1455'
Test #17:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
4766 8958 955796731208347 306051927627717 1030986287617089
output:
4765
result:
wrong answer 1st lines differ - expected: '724934360003094', found: '4765'
Test #18:
score: 0
Wrong Answer
time: 1ms
memory: 1196kb
input:
4675 8280 331918804272602 558377646810381 51805988620085
output:
4674
result:
wrong answer 1st lines differ - expected: '25902994316519', found: '4674'
Test #19:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
8246 2444 1000000000008245 1000000000002443 1589841792991229
output:
10688
result:
wrong answer 1st lines differ - expected: '794920896500959', found: '10688'
Test #20:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
7890 10350 1000000000007889 1000000000010349 787505365966203
output:
7889
result:
wrong answer 1st lines differ - expected: '393752682992221', found: '7889'