QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466866#7689. Flipping Cardsadanmaip#WA 0ms1632kbC++14961b2024-07-08 11:17:332024-07-08 11:17:33

Judging History

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

  • [2024-07-08 11:17:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1632kb
  • [2024-07-08 11:17:33]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
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=0;
	int l=-1, 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+1; i<=r; ++i) w[i].a=w[i].b;
	//for (int i=0; i<n; ++i) printf("%d ", w[i].a);
	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: 100
Accepted
time: 0ms
memory: 1536kb

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: 1632kb

input:

1
2 1

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 1612kb

input:

1
212055293 384338286

output:

384338286

result:

ok 1 number(s): "384338286"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 1608kb

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:

507850962

result:

wrong answer 1st numbers differ - expected: '528957505', found: '507850962'