dp解Codeforces Round #260 (Div. 2)C. Boredom
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
long long shu[100010],fu[100010];
int main()
{
int t,n,i,r=-1,l=100010;
cin>>n;
for(i=0;i<n;i++)
{
cin>>t;
shu[t]++;
l=min(l,t);
r=max(r,t);
}
fu[1]=1*shu[1];
for(i=max(l,2);i<=r;i++)
fu[i]=max(fu[i-1],fu[i-2]+shu[i]*i);
//前i个数(包含i)所能得到的最大分数等于,前i-1个数所能得到的最大分数。和选择第i个数所能得到的最大分数
//它们俩的最大值
cout<<fu[r];
}
dp解Codeforces Round #260 (Div. 2)C. Boredom的更多相关文章
- DP Codeforces Round #260 (Div. 1) A. Boredom
题目传送门 /* 题意:选择a[k]然后a[k]-1和a[k]+1的全部删除,得到点数a[k],问最大点数 DP:状态转移方程:dp[i] = max (dp[i-1], dp[i-2] + (ll) ...
- 递推DP Codeforces Round #260 (Div. 1) A. Boredom
题目传送门 /* DP:从1到最大值,dp[i][1/0] 选或不选,递推更新最大值 */ #include <cstdio> #include <algorithm> #in ...
- Codeforces Round #260 (Div. 1) A - Boredom DP
A. Boredom Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/A ...
- Codeforces Round #260 (Div. 1) A. Boredom (简单dp)
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...
- Codeforces Round #260 (Div. 2)C. Boredom(dp)
C. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #260 (Div. 1) 455 A. Boredom (DP)
题目链接:http://codeforces.com/problemset/problem/455/A A. Boredom time limit per test 1 second memory l ...
- Codeforces Round #260 (Div. 2) A B C 水 找规律(大数对小数取模) dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #260 (Div. 1) Boredom(DP)
Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Round #260 (Div. 2) A , B , C 标记,找规律 , dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
随机推荐
- Java下List使用subList实现分页获取
java.util.List中有一个subList方法,用来返回一个List的一部分的视图. List<E> subList(int fromIndex, int toIndex); 它返 ...
- Solr6 +mmseg4j+IK-Analyzer + SQLserver +DIH 完全配置
如今做任何一个系统都有搜索,而搜索界有著名的三剑客: solr/elasticsearch/sphinx solr/elasticsearch 为同一类的,都是基于lucene开发的产品,本人也早在几 ...
- linux之cat,more,less,head,tail
http://lionbule.iteye.com/blog/663549 1.cat # cat /etc/profile 注:查看/etc/目录下的profile文件内容: # cat -b /e ...
- Ubuntu -- 安装和部署php5.6 nginx php5.6-fpm
1.首先输入用户名和密码进行登录 2.升级更新软件包 sudo apt-get update sudo apt-get upgrade 判断都填y 3.安装nginx sudo apt-get i ...
- dx12 memory management
https://msdn.microsoft.com/en-us/library/windows/desktop/dn508285(v=vs.85).aspx Map with D3D11_MAP_W ...
- 如何格式化被压缩的JS代码以方便阅读
本文分两部分: 1.转载部分 2.个人补充部分 1.主题内容转载83,http://www.madeby83.com/unzip-the-js-code.html 我们经常可以看到一些网站,把所需的j ...
- 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何获取标准驱动器扭矩值获取电流值
双击某个驱动器(以松下伺服驱动器为例),在Process Data中,注意默认显示了PDO mapping1的数据(Error code, status word等) 注意左侧,2和3分别表示了与 ...
- web报表工具FineReport经常使用函数的使用方法总结(日期和时间函数)
web报表工具FineReport经常使用函数的使用方法总结(日期和时间函数) 说明:凡函数中以日期作为參数因子的,当中日期的形式都必须是yy/mm/dd.并且必须用英文环境下双引號(" & ...
- Jersey 1.18 API文档
Jersey 1.18 API文档 我自己制作了Jersey 1.18 API CHM文档, 下载地址见: http://download.csdn.net/detail/chszs/7334869 ...
- Unlink of file 'xx' failed. Should I try again? (y/n) 解决办法
Unlink of file 'xx' failed. Should I try again? (y/n) 原因:一般遇到这个错输入y/n都不能解决问题,出现这个问题的原因可能是其他程序正在操作git ...