题目大意
题解
还是比较有意思的,首先有这样一个想法,把每种能力值最大的都找出来,但是这样会出现一个问题,可能有一个人同时有多种最大值,为了避免这个问题,每次都把拥有多种最大值的人删掉,直接暴力做就可以做到 O ( n 2 ) O(n^2) O(n2),容易优化到 O ( n log n ) O(n\log n) O(nlogn)
code
#include<cstdio>
#include<algorithm>
using namespace std;
#define gc() (fp==fq&&(fq=(fp=fr)+fread(fr,1,1<<20,stdin))==fp?EOF:*fp++)
char fr[1<<21],*fp,*fq;
void read(int &res)
{
res=0;