QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631840#1441. Special GamecherrycatWA 0ms4092kbC++14900b2024-10-12 10:32:342024-10-12 10:32:35

Judging History

This is the latest submission verdict.

  • [2024-10-12 10:32:35]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4092kb
  • [2024-10-12 10:32:34]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x)
{
	x=0;short f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x*=f;return;
}
int n;
int main()
{
	read(n);
	vector<int>a(n),b(n);
	for(int &x:a) read(x);
	for(int &x:b) read(x);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int ans=0,cur=1;
	while(a.size())
	{
		if(a.back()<b[0])
		{
			break;
		}
		if(b.back()<a[0])
		{
			if(cur) ans+=n;
			break;
		}
		pair<int,int>best={-1e9,0};
		for(int i=0,j=0;i<n;++i)
		{
			while(j<n&&a[i]>=b[j]) ++j;
			if(j==n) continue;
			if(i-j>best.first-best.second)
				best={i,j};
		}
		int i=best.first,j=best.second;
		a.erase(a.begin()+i);
		b.erase(b.begin()+j);
		swap(a,b);
		if(!cur) ++ans;
		--n,cur^=1;
	}
	printf("%d\n",ans);
}

詳細信息

Test #1:

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

input:

3
1 2 5
3 4 6

output:

1

result:

ok "1"

Test #2:

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

input:

2
4 3
1 2

output:

2

result:

ok "2"

Test #3:

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

input:

1
1
2

output:

0

result:

ok "0"

Test #4:

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

input:

9
2 12 10 3 4 7 17 14 16
6 1 13 11 9 15 18 8 5

output:

5

result:

ok "5"

Test #5:

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

input:

9
1 3 2 14 15 13 8 6 7
12 11 4 17 9 5 18 10 16

output:

3

result:

ok "3"

Test #6:

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

input:

4
2 8 1 7
5 6 3 4

output:

1

result:

wrong answer 1st words differ - expected: '2', found: '1'