65pts 求助
查看原帖
65pts 求助
523541
Onana_in_XMFLS楼主2023/7/10 20:42
// Problem: P7628 [COCI2011-2012#1] PLES
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P7628
// Memory Limit: 128 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define mem(arr,val) memset((arr),(val),(sizeof(arr)))
using namespace std;
const int maxn = 1e5+5;
int bg[maxn],ba[maxn],gg[maxn],ga[maxn],d1,d2,d3,d4,res;
int main(int argc,char *argv[])
{
	int n;scanf("%d",&n);
	for(int i = 1,x;i <= n;++i)
	{
		scanf("%d",&x);
		x>0?bg[++d1]=x:ba[++d2]=abs(x);
	}
	for(int i = 1,y;i <= n;++i)
	{
		scanf("%d",&y);
		y>0?gg[++d3]=y:ga[++d4]=abs(y);
	}
	sort(bg+1,bg+d1+1);sort(ba+1,ba+d2+1);
	sort(gg+1,gg+d3+1);sort(ga+1,ga+d4+1);
	int down = 1;
	for(int i = 1;i <= d1 && down <= d4;++i)
		if(bg[i] < ga[down]) ++res,++down;
	down = 1;
	for(int i = 1;i <= d2 && down <= d3;++i)
		if(ba[i] > gg[down]) ++res,++down;
	printf("%d\n",res);
	return 0;
}

2023/7/10 20:42
加载中...