CodeVS 4181 三体之期望执剑人 【排序】

tonyfang posted @ 2015年9月22日 16:33 in codevs with tags C++ OI , 679 阅读

一维度排序,一维度找即可。

 

# include <stdio.h>
# include <algorithm>
using namespace std;
struct people {
	int a,b;
}p[100010];
int n;
inline int cmp(struct people s,struct people t) {
	return s.a<t.a || (s.a==t.a&&s.b>t.b);
}
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&p[i].a);
	for (int i=1;i<=n;++i) scanf("%d",&p[i].b);
	sort(p+1,p+n+1,cmp);
	bool f=1;
	while(f) {
		f=0;
		int ans=0;
		for (int i=2;i<=n;++i)
			if(p[i-1].a==p[i].a||p[i].b<=p[i-1].b) p[++ans]=p[i-1];
			else f=1;
		p[++ans]=p[n];
		n=ans;
	}
	printf("%d\n",n);
	return 0;
}
https://pucresult201 说:
2023年4月15日 22:38

Pucresult 2023 is a start-up by passionate webmasters and bloggers who have a passion to provide engaging content which is accurate, interesting, and worthy to read. We are more like a web community where you can find different information, resources, and topics on day-to-day incidents or news. https://pucresult2019.com/ We provide you the finest of web content on each and every topic possible with help of an editorial and content team Our site is a multiple Niche or category website which will ensure to provide informational and resources on each and every topic.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter