QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#847845 | #9989. Harmful Machine Learning | The_Shadow_Dragon | AC ✓ | 197ms | 4244kb | C++14 | 965b | 2025-01-08 11:52:52 | 2025-01-08 11:52:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sort stable_sort
#define endl '\n'
int a[200010];
priority_queue<int,vector<int>,less<int> >q1;
priority_queue<int,vector<int>,greater<int> >q2;
int main()
{
// #define Isaac
#ifdef Isaac
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
int t,n,x,i,j;
cin>>t;
for(j=1;j<=t;j++)
{
cin>>n>>x;
while(q1.empty()==0)
{
q1.pop();
}
while(q2.empty()==0)
{
q2.pop();
}
for(i=1;i<=n;i++)
{
cin>>a[i];
if(abs(i-x)<=1)
{
q1.push(a[i]);
}
else
{
q2.push(a[i]);
}
}
sort(a+1,a+1+n);
if(n<=4)
{
cout<<a[min(3,n)]<<endl;
}
else
{
if(q1.top()>q2.top())
{
q1.push(q2.top());
q2.pop();
q2.push(q1.top());
q1.pop();
}
cout<<(q1.size()==2?max(q1.top(),q2.top()):q1.top())<<endl;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
4 3 2 1 2 3 13 4 1 1 4 5 1 4 1 9 1 9 8 1 0 4 2 1 10 100 1000 1 1 114514
output:
3 4 100 114514
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 88ms
memory: 3656kb
input:
100000 1 1 1 5 4 1 0 0 0 0 5 4 0 1 1 0 1 2 2 1 1 1 1 1 4 3 0 0 0 1 1 1 0 2 1 1 0 2 2 0 1 3 3 0 0 1 3 1 1 0 0 1 1 1 2 1 0 1 5 4 0 1 1 1 1 1 1 1 5 5 0 0 0 1 0 2 1 1 0 4 4 1 0 0 1 3 2 0 0 1 5 3 1 1 1 0 1 3 3 0 0 1 2 2 1 1 4 1 1 1 0 1 4 1 0 0 1 1 1 1 0 5 4 1 0 1 0 0 4 3 0 0 1 1 1 1 1 3 3 0 1 1 5 4 1 0 0...
output:
1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 0 0 1 0 0 1 1 1 1 ...
result:
ok 100000 lines
Test #3:
score: 0
Accepted
time: 124ms
memory: 3660kb
input:
100000 2 2 59820207 376803742 3 2 208862368 319232484 27144855 4 3 773899181 465093098 722012192 436481034 2 1 780276037 871545470 1 1 710180001 1 1 420011585 3 1 385108264 307138942 241489653 5 4 737902242 315557098 600286836 883838302 938250085 2 2 806646512 330829636 4 3 856420721 973701499 43835...
output:
376803742 319232484 722012192 871545470 710180001 420011585 385108264 883838302 806646512 856420721 554247848 960484949 415586825 616215879 303945379 472961236 417431687 796718792 421695538 725220942 745175356 983721950 617752199 100888645 431107906 940001412 524096689 678058393 500133506 791526145 ...
result:
ok 100000 lines
Test #4:
score: 0
Accepted
time: 55ms
memory: 3664kb
input:
5000 97 63 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 1 0 1 0 1 1 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 100 84 0 0 0 1 0 0 1 1 1 1 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 1 1 0 1 ...
output:
1 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 1 1 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 1 1 0 0 ...
result:
ok 5000 lines
Test #5:
score: 0
Accepted
time: 162ms
memory: 3660kb
input:
5000 99 23 245383290 713605975 531798224 226352028 148585673 128822098 941255594 732638998 681385595 478765463 975653864 505509784 192432526 425852063 320067034 936708813 915826771 885705362 209406568 252688724 121970882 808334022 112437199 26049855 887584365 207006659 408893033 714973271 908106728 ...
output:
112437199 427773110 173324287 614384607 118623872 348288246 740787251 230166589 599956553 337623672 323899213 296369508 494474410 388176143 692525806 139834595 700996689 194262517 176771414 428997177 282865655 637056743 480092314 565849593 260426697 379209896 128588598 500981520 798969798 639906593 ...
result:
ok 5000 lines
Test #6:
score: 0
Accepted
time: 61ms
memory: 4244kb
input:
5 99996 91786 1 0 0 1 1 1 1 0 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1 1 1 ...
output:
1 1 1 1 1
result:
ok 5 lines
Test #7:
score: 0
Accepted
time: 189ms
memory: 4224kb
input:
5 100000 21243 6564449 666078040 316794579 713886960 778793470 279091226 793133392 682279300 600458322 80387254 110453491 905290224 340389407 810013264 620883419 811912358 355091137 42088811 195829643 679425305 683352253 533052895 20783444 356486689 740001089 467432460 271141495 385792562 164724850 ...
output:
469948270 761396749 929129528 568041451 247965688
result:
ok 5 lines
Test #8:
score: 0
Accepted
time: 150ms
memory: 3648kb
input:
5000 99 1 1587981 6817974 618357267 923294422 658765262 449325854 480048774 818346068 404650899 336008146 769581248 210969129 978265172 948174601 162263128 657853437 776441263 453932767 90984288 388408089 980716853 723277460 791920003 972578436 146535301 483824970 513954865 429988060 214169446 80447...
output:
7491252 17737104 20291601 11076580 33213736 48760007 18932470 6018471 40782371 31799675 4441436 52446773 26713887 36191422 35154578 64527050 7531207 34408197 15368750 7196134 43175679 25206057 19707467 5359011 35486250 35832323 40649416 17238299 10575020 24251834 6558789 12088443 18799997 31853553 6...
result:
ok 5000 lines
Test #9:
score: 0
Accepted
time: 171ms
memory: 3676kb
input:
500 996 996 698416030 787933962 538760604 470067060 443803749 406247744 200177401 283777832 509464632 366586537 833644775 226151123 158732734 939734763 356056121 394186843 127067897 572567601 186226768 679761418 366101302 533710945 247150566 160860746 107123133 507346041 502614113 352755589 45461102...
output:
3180777 3874257 3676606 1775576 1530385 2281001 1739411 3112703 1373057 2746862 1406063 2130392 3219954 2154553 2262209 5035002 2290140 3069698 1520968 2066024 1071863 1202588 1706011 3661085 1324865 2401344 3189079 4228785 3082257 744422 1533730 1017922 1897536 1296868 3369455 1783859 3942849 11485...
result:
ok 500 lines
Test #10:
score: 0
Accepted
time: 197ms
memory: 4240kb
input:
5 99996 36519 954714549 866623225 866142198 746530025 724072979 790713229 704805731 557656562 587568865 437771255 566208359 807360413 861744134 565725771 223640634 182237746 552903568 178908309 637980492 361050449 361956344 118328525 681523958 245918544 94148754 506264321 279215400 96172689 11918495...
output:
17806 19041 6987 40085 5471
result:
ok 5 lines