博客
关于我
codeforce round625 div2 (a+b)map
阅读量:618 次
发布时间:2019-03-13

本文共 530 字,大约阅读时间需要 1 分钟。

第一题很简单,但是我做的时候一直re,之后发现少考虑了一种分母为零的情况,导致程序提前退出,需要注意一下,不多阐述,下面是b题

在这里插入图片描述
这道题的大意是对于一组数据,每个数对应一个价值如果满足序号差等于价值差他们可以组成一组问最大的组合大小,我看完题的第一想法是一个n方的dp,。大概就是从小到大依次确定当前的最优解,也就是说对于每个位置i我们需要遍历1到i-1的过程如果满足ci+1-ci=bi+1-bi就尝试更新保证过程量一定是对的,但是复杂度不理想。
所以我们换一个角度去看这个问题对于这个式子ci+1-ci=bi+1-bi。移项后我们发现只需满足ci+1-bi+1=ci-bi即可也就是说我们只需把自身差相等的所有项的价值累加即可,而这个操作我们借助map可以很简单的达到

#include
#define ll long long using namespace std;int main(){ ll n; cin>>n; map
mp; ll a; ll ma=0; for(int i=1;i<=n;i++){ cin>>a; mp[a-i]+=a; ma=max(ma,mp[a-i]); } cout<

转载地址:http://hdpaz.baihongyu.com/

你可能感兴趣的文章
nginx+php的搭建
查看>>
Nginx+Redis+Ehcache:大型高并发与高可用的三层缓存架构总结
查看>>
nginx+tomcat+memcached
查看>>
nginx+tomcat单个域名及多个域名配置
查看>>
Nginx+Tomcat实现动静分离
查看>>
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
Nginx/Apache反向代理
查看>>
Nginx: 413 – Request Entity Too Large Error and Solution
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>
Nginx:objs/Makefile:432: recipe for target ‘objs/src/core/ngx_murmurhash.o‘解决方法
查看>>
nginxWebUI runCmd RCE漏洞复现
查看>>
nginx_rtmp
查看>>
Vue中向js中传递参数并在js中定义对象并转换参数
查看>>