ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#208274 | #3760. 中位数 | wyz_ | 100 | 1450ms | 17092kb | C++11 | 708b | 2024-08-02 09:24:29 | 2024-08-02 12:06:31 |
answer
#include<bits/stdc++.h>
using namespace std;
int n,mid,a[2000005];
priority_queue<int>pq_n;
priority_queue<int,vector<int>,greater<int>>pq_x;
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
cout << (mid = a[1]) << '\n';
for(int i = 2; i <= n; i += 2){
a[i] < mid ? pq_n.push(a[i]) : pq_x.push(a[i]);
a[i+1] < mid ? pq_n.push(a[i+1]) : pq_x.push(a[i+1]);
if(pq_x.size() > pq_n.size()){
pq_n.push(mid);
mid = pq_x.top();
pq_x.pop();
}
else if(pq_n.size() > pq_x.size()){
pq_x.push(mid);
mid = pq_n.top();
pq_n.pop();
}
cout << mid << '\n';
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1292kb
input:
999 500000349 500000416 500000169 500000400 500000251 500000501 500000004 500000484 500000326 500000...
output:
500000349 500000349 500000349 500000349 500000349 500000326 500000281 500000251 500000278 500000251 ...
result:
ok 500 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 1292kb
input:
999 500000222 500000210 500000343 500000339 500000232 500000115 500000462 500000269 500000231 500000...
output:
500000222 500000222 500000232 500000232 500000232 500000232 500000232 500000232 500000232 500000231 ...
result:
ok 500 lines
Test #3:
score: 10
Accepted
time: 0ms
memory: 1292kb
input:
999 500000312 500000111 500000373 500000171 500000011 500000135 500000130 500000148 500000284 500000...
output:
500000312 500000312 500000171 500000135 500000148 500000171 500000171 500000171 500000200 500000200 ...
result:
ok 500 lines
Test #4:
score: 10
Accepted
time: 0ms
memory: 1288kb
input:
999 500000244 500000352 500000490 500000386 500000026 500000381 500000010 500000267 500000265 500000...
output:
500000244 500000352 500000352 500000352 500000267 500000267 500000265 500000265 500000267 500000267 ...
result:
ok 500 lines
Test #5:
score: 10
Accepted
time: 16ms
memory: 2048kb
input:
99999 500054267 500035412 500041365 500038761 500034334 500015071 500020907 500007213 500058496 5000...
output:
500054267 500041365 500038761 500035412 500035412 500034334 500030136 500023452 500030136 500034334 ...
result:
ok 50000 lines
Test #6:
score: 10
Accepted
time: 15ms
memory: 2120kb
input:
99999 500006290 500034296 500017269 500004468 500009242 500018632 500056010 500055653 500026987 5000...
output:
500006290 500017269 500009242 500017269 500018632 500018632 500018632 500018632 500026987 500018632 ...
result:
ok 50000 lines
Test #7:
score: 10
Accepted
time: 15ms
memory: 2116kb
input:
99999 500034174 500012905 500059611 500030852 500006349 500056601 500040197 500050573 500048073 5000...
output:
500034174 500034174 500030852 500034174 500040197 500034174 500030852 500020997 500030843 500030843 ...
result:
ok 50000 lines
Test #8:
score: 10
Accepted
time: 382ms
memory: 17000kb
input:
1999999 501757318 500661812 501838931 501096674 501347961 500244154 500892159 501858821 500964235 50...
output:
501757318 501757318 501347961 501096674 501096674 501096674 501096674 501038815 501038815 501002394 ...
result:
ok 1000000 lines
Test #9:
score: 10
Accepted
time: 363ms
memory: 17004kb
input:
1999999 501485921 501744371 501128867 500751126 501658197 501136617 500406037 500448369 500746821 50...
output:
501485921 501485921 501485921 501136617 501128867 501128867 501136617 501128867 501119509 501128867 ...
result:
ok 1000000 lines
Test #10:
score: 10
Accepted
time: 659ms
memory: 17092kb
input:
1999999 501679123 501742012 501806641 500774076 501854402 501571146 501073353 500345154 500367723 50...
output:
501679123 501742012 501742012 501679123 501571146 501073353 501073353 501057056 501057056 501057056 ...
result:
ok 1000000 lines
Extra Test:
score: 0
Extra Test Passed