和51nod1055 一样;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<time.h>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 5005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
#define mclr(x,a) memset((x),a,sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-5
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii; inline int rd() {
int x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int n;
int a[maxn];
int dp[5005][5005];
int main()
{
// ios::sync_with_stdio(0);
n = rd();
for (int i = 1; i <= n; i++) {
a[i] = rd();
}
sort(a + 1, a + 1 + n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++)dp[i][j] = 2;
}
int ans = 2;
for (int i = 1; i <= n - 1; i++) {
int pre = i - 1;
for (int j = i + 1; j <= n; j++) {
while (pre > 0 && a[j] - a[i] > a[i] - a[pre])pre--;
if (!pre)break;
if (pre > 0 && a[j] - a[i] == a[i] - a[pre])
dp[j][i] = max(dp[j][i], dp[i][pre] + 1);
ans = max(ans, dp[j][i]);
}
}
cout << ans << endl;
return 0;
}

最新文章

  1. 遇到的Exception/error及解决办法记录汇总
  2. 整合SSM时报错:java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer;
  3. 简单的射击游戏HTML+JS实现
  4. [译]git reset
  5. 矩阵快速幂 ZOJ 3497 Mistwald
  6. C# 使用HttpWebRequest通过PHP接口 上传文件
  7. 越狱Season 1-Episode 7: Riots, Drills and the Devil: Part 2
  8. Android模拟器常用命令收录
  9. jQuery模拟点击A标记
  10. 关于ASP.NET Web Api的HelpPage文档注释问题
  11. 006. SSO 单点登录(同域SSO/跨域SSO)
  12. Windows Server 2008 R2 Enterprise x64 部署 nginx、tomcat、mysql
  13. Spring @Autowired注解在非Controller中注入为null
  14. c语言搜索子字符串
  15. select2 清除选中项解决办法
  16. 线段树专题2-(加强版线段树-可持续化线段树)主席树 orz! ------用于解决区间第k大的问题----xdoj-1216
  17. 笨方法学python之转义字符
  18. Oracle 11g安装,新建表空间和用户
  19. 管理node.js版本的模块:n
  20. Swift4 - 动态计算UITableView中tableHeaderView的高度 - 获取子控件高度和宽度

热门文章

  1. Mysql问题随记
  2. PHP数据结构之五 栈的PHP的实现和栈的基本操作
  3. laravel 队列
  4. 在TFS中获取项目,获取最新和上传(迁入)
  5. Base -快捷键|通配符|特殊符号|输出(正确与错误的保存)
  6. SQL SERVER 2008权限配置
  7. Django框架 之 modelform组件
  8. JavaScript——Dom编程(1)
  9. open与fopen的用法
  10. delphi 数组的使用