-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.cpp
More file actions
56 lines (48 loc) · 1.23 KB
/
1.cpp
File metadata and controls
56 lines (48 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
t/*************************************************************************
> File Name: 1.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月04日 星期五 21时41分59秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 100086;
int num[15][N];
int dp[15][N];
int main()
{
int n;
while(~scanf("%d", &n) && n)
{
memset(dp, 0, sizeof(dp));
memset(num, 0, sizeof(num));
int ma = 0;
int T = 0;
for(int i = 0; i < n; i++)
{
int t, x;
scanf("%d%d", &x, &t);
num[x+1][t]++;
if(t > T) T = t;
}
for(int t = 1; t <= T; t++)
{
int l = t<6 ? 6-t : 1;
int r = t<6 ? 6+t : 11;
for(int i = l; i <= r; i++)
{
dp[i][t] = num[i][t] + max(dp[i][t-1], max(dp[i+1][t-1], dp[i-1][t-1]));
}
for(int i = 1; i <= 11; i++)
if(dp[i][T] > ma)
ma = dp[i][T];
}
cout<<ma<<endl;
}
return 0;
}