A. Boredom【DP】

用哈希表存一下每个数出现的个数。考虑每一个数选不选依赖于前一个数。 https://codeforces.com/problemset/problem/455/A
#include
using namespace std;
typedef long long int LL;
const int N=1e5+10;
int a[N],cnt[N],n,maxv;
LL f[N][2];
int main(void)
{
cin>>n;
for(int i=1;i<=n;i++) { cin>>a[i];
maxv=max(maxv,a[i]);
cnt[a[i]]++;
}
//f[i][0]表示考虑前i个数且i不选
//f[i][0]表示考虑前i个数且i选
for(int i=

A. Boredom【DP】最先出现在Python成神之路

版权声明:
作者:dingding
链接:https://www.techfm.club/p/26340.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>