QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#466852#7689. Flipping Cardsadanmaip#WA 0ms1532kbC++14859b2024-07-08 11:05:032024-07-08 11:05:03

Judging History

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

  • [2024-07-08 11:05:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1532kb
  • [2024-07-08 11:05:03]
  • 提交

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;
}

詳細信息

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'