|洛谷|贪心|P1413 坚果保龄球

https://www.luogu.org/problem/show?pid=1413

把僵尸按照t为关键字从小到大排序,t相同时p为关键字

然后用a数组来存储每一道最早能拦截到的一个僵尸的编号

如果道一样,当前僵尸出现时间-之前的僵尸>=60说明这一个坚果拦不到,要增加一个

#include
#include
#include
#define ms(i,j) memset(i,j, sizeof i);
/*	NOIP2016倒计时,RP++ 
	Luogu: P1413 坚果保龄球
*/
using namespace std; 
struct node
{
	int p,t;
}s[2005];
bool cmp(const node &a, const node &b)
{
	if (a.t==b.t) return a.p= 60)
		{
			ans++;
			a[s[i].p] = i;
		}
	}
	printf("%d\n", ans);
    return 0;
}


你可能感兴趣的:(贪心,洛谷)