zoj 3519 Who is the Smartest Man

//简单的贪心题!主要是先对输入的数组进行排序!
#include "iostream"
#include "algorithm"
#include "memory.h"
using namespace std;

int points[510];

int main()
{
	int N, IP, i, count;
	while (cin >> N >> IP)
	{
		memset(points, 0, sizeof(points));
		count = 0;
		for (i = 0; i < N; i++)
			cin >> points[i];
		sort(points, points + N);
		for (i = 0; i < N; i++)
		{
			if (points[i] > IP)
				IP += 2;
			else
				count++;
		}
		IP += count;
		cout << IP << endl;
	}
}

你可能感兴趣的:(zoj 3519 Who is the Smartest Man)