QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#846899#9989. Harmful Machine Learningzhenjianuo2025AC ✓45ms5944kbC++201.7kb2025-01-07 15:39:392025-01-07 15:39:39

Judging History

你现在查看的是最新测评结果

  • [2025-01-07 15:39:39]
  • 评测
  • 测评结果:AC
  • 用时:45ms
  • 内存:5944kb
  • [2025-01-07 15:39:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ins insert
#define era erase
#define lb lower_bound
#define ub upper_bound
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) (int)((vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.pb(b);}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define quit(sth) {sth;return;}
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define int long long
#define inf (long long)(1e18)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
const int mod=998244353;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
void Dec(int &x,int y){x=x>=y?x-y:x-y+mod;}
int fpm(int x,int y){
    int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}


int n,x,a[500010];
bool chk(int L){
    int cnt=0;
    for(int i=x-1;i<=x+1;i++)
        cnt+=a[i]>=L;
    if(cnt>=2)return 0;
    cnt=0;
    for(int i=1;i<=n;i++)
        cnt+=a[i]<L;
    if(cnt<3)return 0;return 1;
}
void work(){
    cin>>n>>x;
    for(int i=1;i<=n;i++)cin>>a[i];
    if(n==1)quit(cout<<a[1]<<'\n');
    if(n==2)quit(cout<<max(a[1],a[2])<<'\n');
    a[n+1]=0;
    int l=0,r=1e9,mid;
    while(l<r){
        if(chk(mid=(l+r+1)>>1)){
            r=mid-1;
        }else l=mid;
    }       cout<<l<<'\n';
}
signed main(){
    ios::sync_with_stdio(0),
    cin.tie(0),cout.tie(0);
    int T=1;cin>>T;while(T--)work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

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: 32ms
memory: 3728kb

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: 45ms
memory: 3604kb

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: 26ms
memory: 3728kb

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: 37ms
memory: 3728kb

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: 22ms
memory: 5788kb

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: 31ms
memory: 5944kb

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: 41ms
memory: 3612kb

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: 35ms
memory: 3624kb

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: 32ms
memory: 4380kb

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