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 ...
随机推荐
- Android 中AlarmManager升级4.2
- Apache -Common-lang包使用
原文:http://weigang-gao.iteye.com/blog/2188739 ArrayUtils – 用于对数组的操作,如添加.查找.删除.子数组.倒序.元素类型转换等: BitFiel ...
- php新浪云链接mysql与storage
1.首先要有一个新浪云服务器 2.链接数据库获取数据 mysql CREATE TABLE Persons(FirstName varchar(255),LastName varchar(255)); ...
- Node.js 调用 restful webservice
如何构建一个restful web service参考原来的文章 http://www.cnblogs.com/ericnie/p/5212748.html 直接用原来的项目编译好像有问题,此处耗费1 ...
- CMD/AMD的原理、区别和应用
有必要简单提一下两者的主要区别: 1.CMD推崇依赖就近,可以把依赖写进你的代码中的任意一行,例: define(function(require, exports, module) { var a ...
- SSH 错误解决案例1:Read from socket failed: Connection reset by peer
今天早上天天连接的开发机突然报出连接错误. 这个错误是SSH最常见错误,造成的原因也是千奇百怪(具体可goole),下面描述我的server的问题: 客户端报错 [root@server]# ssh ...
- Docker默认存储路径修改
Docker默认存储路径: # docker info...... Data loop file: /var/lib/docker/devicemapper/devicemapper/data.... ...
- IEEE会议投稿资料汇总http://cadcg2015.nwpu.edu.cn/index.htm
近期投了篇IEEE的顶级会议文章,一下是比較实用的一些资料,以供參考. 1.会议主页:http://cadcg2015.nwpu.edu.cn/index.htm (The 14th Inte ...
- 解决Linux下3T硬盘分区只有2T(2199G)可用
分区转换成GPT即可 sudo parted /dev/sdb 将MBR硬盘格式化为GPT mklabel gpt 之后可以看一下状态 print 整个硬盘空间只分一个区 mkpart primary ...
- 在ASP.NET MVC中支持 HttpHandler
写HttpHandler与ASP.NET WebForm基本没有什么不同.只是部署的时候需要注意,只在Web.config中注册还不行,需要在Global.asax.cs添加一条ignore规则: p ...