思路
类似大盗阿福,就是价值变了一下。
记得开\(long~long\)(吼)
记得开\(long~long\)(吼)
记得开\(long~long\)(吼)
重要事情说三遍
代码
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 100010;
int n;
LL cnt[N];
LL f[N];
int main () {
cin >> n;
for (int i = 1;i <= n;i++) {
int x;
cin >> x;
cnt[x]++;
}
f[1] = cnt[1];
for (int i = 2;i < N;i++) f[i] = max (f[i - 1],f[i - 2] + (cnt[i] ? i * cnt[i] : 0));
cout << f[N - 1] << endl;
return 0;
}
标签:cnt,1.455,int,LL,long,Boredom,Div,include
From: https://www.cnblogs.com/incra/p/16782451.html