QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#420333 | #8370. T3 | C1942huangjiaxu | 0 | 10ms | 6156kb | C++14 | 833b | 2024-05-24 16:36:28 | 2024-05-24 16:36:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,m,a[N],b[N],va,vb,pa,pb,h[N];
ll s[N];
bool check(int d){
ll t=0,mx1=0,mx2=0,j=m,x=0,y=0;
while(x<n&&a[x+1]+b[j]<d)x++;
for(int i=n-1;~i;--i){
while(y<m&&a[i+1]+b[y+1]<d)y++;
t+=m-j-y;
while(j&&n-x-i>0){
t+=n-x-i,j--;
while(j&&x<n&&a[x+1]+b[j]<d)x++;
}
mx1=max(mx1,t);
if(pa<=i||pb<=j)mx2=max(mx2,t);
}
return mx1==mx2;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)scanf("%d",&a[i]);
for(int i=1;i<=m;++i)scanf("%d",&b[i]);
va=a[1],vb=b[1];
sort(a+1,a+n+1);
sort(b+1,b+m+1);
pa=lower_bound(a+1,a+n+1,va)-a;
pb=lower_bound(b+1,b+m+1,vb)-b;
int l=1,r=va+vb;
while(l<r){
int mid=l+r>>1;
if(check(mid))r=mid;
else l=mid+1;
}
printf("%d\n",l);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 14
Accepted
time: 1ms
memory: 5840kb
input:
3 4 5793102 5457652 10631669 14037022 24564522 19828638 16740187
output:
19830124
result:
ok 1 number(s): "19830124"
Test #2:
score: -14
Wrong Answer
time: 1ms
memory: 5928kb
input:
4 4 24461545 7466923 15331834 20936291 21465585 2271163 23099576 8980678
output:
29916970
result:
wrong answer 1st numbers differ - expected: '29916969', found: '29916970'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 10ms
memory: 6156kb
input:
58907 56480 44575563 540879 28467036 43621838 25515388 10048620 4501896 38628765 39419406 29497118 41954017 917402 20191987 40236908 12585166 22986979 1764011 21587278 32837245 20261107 20671792 37064770 22652008 6411880 34950023 5163325 17409659 46335787 11065741 6440463 44544150 13934453 19477226 ...
output:
23107970
result:
wrong answer 1st numbers differ - expected: '23107969', found: '23107970'
Subtask #3:
score: 0
Wrong Answer
Test #21:
score: 15
Accepted
time: 1ms
memory: 5928kb
input:
3 10 24332538 25602471 54833728 7466852 20176810 23770883 13240181 15036268 16178071 19850557 11751859 12686516 11159532
output:
31799390
result:
ok 1 number(s): "31799390"
Test #22:
score: -15
Wrong Answer
time: 1ms
memory: 5804kb
input:
4 9 14880669 10667567 7977836 1882967 80951479 5481207 15459896 52525030 28052486 14797866 34391066 58754229 27619130
output:
38286698
result:
wrong answer 1st numbers differ - expected: '38286697', found: '38286698'
Subtask #4:
score: 0
Wrong Answer
Test #34:
score: 0
Wrong Answer
time: 0ms
memory: 5928kb
input:
557 24 944055 6651285 6872647 7501680 6728901 5684173 78312 872911 5349349 5834868 1104965 5034609 943636 6298640 4862332 6874311 4925018 7027588 6656184 1303888 1092633 6129416 3629195 5717171 4703294 6929327 6147793 2666674 4531679 3785633 7473654 274978 7723474 1969517 3520566 5338238 380308 7691...
output:
41467743
result:
wrong answer 1st numbers differ - expected: '41467742', found: '41467743'
Subtask #5:
score: 0
Wrong Answer
Test #47:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
557 24 944055 6651285 6872647 7501680 6728901 5684173 78312 872911 5349349 5834868 1104965 5034609 943636 6298640 4862332 6874311 4925018 7027588 6656184 1303888 1092633 6129416 3629195 5717171 4703294 6929327 6147793 2666674 4531679 3785633 7473654 274978 7723474 1969517 3520566 5338238 380308 7691...
output:
41467743
result:
wrong answer 1st numbers differ - expected: '41467742', found: '41467743'
Subtask #6:
score: 0
Wrong Answer
Test #64:
score: 0
Wrong Answer
time: 0ms
memory: 3960kb
input:
557 24 944055 6651285 6872647 7501680 6728901 5684173 78312 872911 5349349 5834868 1104965 5034609 943636 6298640 4862332 6874311 4925018 7027588 6656184 1303888 1092633 6129416 3629195 5717171 4703294 6929327 6147793 2666674 4531679 3785633 7473654 274978 7723474 1969517 3520566 5338238 380308 7691...
output:
41467743
result:
wrong answer 1st numbers differ - expected: '41467742', found: '41467743'