QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#466852 | #7689. Flipping Cards | adanmaip# | WA | 0ms | 1532kb | C++14 | 859b | 2024-07-08 11:05:03 | 2024-07-08 11:05:03 |
Judging History
answer
#include <cstdio>
#include <algorithm>
struct asd{
int a;
int b;
int ind;
int c;
}w[300001];
bool cmp1(asd ar, asd br){
return ar.a<br.a;
}
bool cmp2(asd ar, asd br){
return ar.ind<br.ind;
}
int main(){
int n;
scanf("%d", &n);
for (int i=0; i<n; ++i){
scanf("%d %d", &w[i].a, &w[i].b);
w[i].ind=i;
}
std:: sort(w, w+n, cmp1);
for (int i=0; i<n; ++i){
if (w[i].b>w[n/2].a) ++w[i].c;
else if (w[i].b<w[n/2].a) --w[i].c;
}
std:: sort(w, w+n, cmp2);
for (int i=0; i<n; ++i) w[i].c+=w[i-1].c;
int maxxx=0, minn=0x3f3f3f3f;
int l=0, r=0;
for (int i=0; i<n; ++i){
if (w[i].c-minn>maxxx){
maxxx=w[i].c-minn;
r=i;
}
if (w[i].c<minn){
minn=w[i].c;
l=i;
}
}
if (maxxx>0) for (int i=l; i<=r; ++i) w[i].a=w[i].b;
std:: sort(w, w+n, cmp1);
printf("%d\n", w[n/2].a);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1532kb
input:
5 3 6 5 2 4 7 6 4 2 8
output:
4
result:
wrong answer 1st numbers differ - expected: '6', found: '4'