QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246224 | #7689. Flipping Cards | fAKeZero# | WA | 65ms | 6532kb | C++17 | 1.1kb | 2023-11-10 17:29:30 | 2023-11-10 17:29:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int w=0,x=0;char c=getchar();
while(!isdigit(c)) w|=c=='-',c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return w?-x:x;
}
namespace star
{
const int maxn=3e5+10;
int n,a[maxn],b[maxn],c[maxn],cnt;
inline bool check(int x){
int s=0,mx=0,MX=0;
for(int i=1;i<=n;i++){
if(a[i]>=x) s++;
if(b[i]>=x and a[i]<x) mx++;
if(a[i]>=x and b[i]<x) mx=max(0,mx-1);
MX=max(MX,mx);
}
return s+MX>n/2;
}
inline void work(){
n=read();
for(int i=1;i<=n;i++) a[i]=read(),b[i]=read(),c[++cnt]=a[i],c[++cnt]=b[i];
sort(c+1,c+1+cnt);
for(int i=1;i<=n;i++) a[i]=lower_bound(c+1,c+1+cnt,a[i])-c,b[i]=lower_bound(c+1,c+1+cnt,b[i])-c;
int l=1,r=cnt,ans=1;
while(l<=r){
int mid=(l+r)/2;
if(check(mid)) ans=mid,l=mid+1;
else r=mid-1;
}
printf("%d\n",c[ans]);
}
}
signed main(){
star::work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5616kb
input:
5 3 6 5 2 4 7 6 4 2 8
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5776kb
input:
1 2 1
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
1 212055293 384338286
output:
384338286
result:
ok 1 number(s): "384338286"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5648kb
input:
99 749159996 323524232 125448341 365892333 481980673 143665393 394405973 44741918 687549448 513811513 287088118 385131171 11865696 666468353 449920567 373650719 671547289 116780561 41003675 671513243 351534153 507850962 374160874 985661954 222519431 600582098 987220654 704142246 856147059 37783620 1...
output:
528957505
result:
ok 1 number(s): "528957505"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
101 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000...
output:
1000000000
result:
ok 1 number(s): "1000000000"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
103 66 46 41 70 52 76 26 5 54 2 78 21 22 39 100 15 73 94 56 7 45 72 76 80 6 67 12 8 86 53 26 1 5 57 90 44 81 85 2 70 32 79 95 42 97 37 87 93 2 21 21 42 29 25 61 35 98 99 33 46 51 10 45 56 40 75 71 25 79 37 75 10 34 98 1 22 40 12 14 81 83 29 51 12 37 96 74 11 30 49 39 34 68 68 36 17 3 55 41 32 22 92 ...
output:
55
result:
ok 1 number(s): "55"
Test #7:
score: 0
Accepted
time: 3ms
memory: 5628kb
input:
5555 884376710 45124731 564350738 110566376 82266416 71890085 742302826 424812817 441684523 786251012 1208704 118200627 206028578 736388312 179371956 412238226 562783304 721943945 855108903 710808533 969831121 89689888 833625410 9559177 39704951 153974475 778740527 562223006 103796470 968790365 2050...
output:
520583648
result:
ok 1 number(s): "520583648"
Test #8:
score: 0
Accepted
time: 24ms
memory: 6040kb
input:
55555 407954959 925854335 331922620 685714089 683072900 978458276 462828931 975317170 524480939 832278948 759453127 157033854 246638012 738429531 423955730 483191182 541683890 709827850 309667569 360334083 797868492 960421332 981833589 59185699 53482766 56438082 56804787 566838744 76359614 376208064...
output:
506121745
result:
ok 1 number(s): "506121745"
Test #9:
score: -100
Wrong Answer
time: 65ms
memory: 6532kb
input:
155555 598245381 667586986 31130797 648468145 839307239 705727216 146732291 106428416 157005415 48720198 868350611 519788697 499861343 881904424 995572615 441419419 119284329 335071863 413173260 485799366 519666020 413812470 731682515 630429185 743423219 948725454 882249618 79486422 811743485 533827...
output:
538911120
result:
wrong answer 1st numbers differ - expected: '500787268', found: '538911120'