您的位置:首页 > 其它

HDU 1176

2015-07-08 12:30 169 查看
#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 100005;
int inp[MAX_V][11], dp[MAX_V][11], N, max_t;
void solve()
{
	for (int i = max_t - 1; i >= 0; i--)
		for (int j = 0; j <= 10; j++)
			dp[i][j] = max(dp[i + 1][j] + inp[i + 1][j], max((!j ? 0 : dp[i + 1][j - 1] + inp[i + 1][j - 1]), (j - 10 == 0 ? 0 : dp[i + 1][j + 1] + inp[i + 1][j + 1])));
	cout << dp[0][5] << endl;
}
int main(int argc, char const *argv[])
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while (cin >> N && N)
	{
		memset(dp, 0, sizeof(dp));
		memset(inp , 0, sizeof(inp));
		int T, X;
		while (N--)
		{
			cin >> X >> T;
			inp[T][X]++;
			max_t = max(max_t, T);
		}
		solve();
	}
	return 0;
}
这道题做过一遍了,自信写完,不对!蒙了,
她输入先x再t,simple中倒着写的,没注意
读题还是很关键啊啊
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: