喵到旁邊的標籤,被雷QQ
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<vector>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<cmath>
using namespace std;
typedef long long int int64;
int64 cnt[100001] = {0};
int64 dp[100001][2] = {0};
int main()
{
int n; scanf("%d", &n);
while(n--){
int64 inp;scanf("%I64d", &inp);
cnt[inp] += inp;
}
for(int lx = 1;lx <= 100000;lx++){
dp[lx][0] = max(dp[lx-1][0], dp[lx-1][1]);
dp[lx][1] = dp[lx-1][0] + cnt[lx];
}
printf("%I64d\n", max(dp[100000][0], dp[100000][1]));
return 0;
}
沒有留言:
張貼留言