博客
关于我
Codeforces Round #615 (Div. 3) D. MEX maximizing(思维好题)
阅读量:400 次
发布时间:2019-03-05

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

在这里插入图片描述
在这里插入图片描述
题意:给定q次询问和x,每次询问都会加入一个数到数组(数组初始为空),你每次可以对数组中的任一数进行+x和-x的操作,问你当前数组未出现的最小整数。
思路:连E和F都做出来了居然卡在这一题,感觉自己好像思维能力和观察能力不行。。。。
其实每次可以无限加X和减去X就应该想到结果只会对x的模数有影响,找空位就行了。

#include
using namespace std;const int maxn=4e5+10;int a[maxn];int main(){ int q,x,t,ans=0; scanf("%d%d",&q,&x); while(q--) { scanf("%d",&t); a[t%x]++; while(a[ans%x]) a[ans%x]--,ans++; printf("%d\n",ans); } }

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

你可能感兴趣的文章
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 ./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
查看>>
Nginx、HAProxy、LVS
查看>>
nginx一些重要配置说明
查看>>
Nginx下配置codeigniter框架方法
查看>>
Nginx与Tengine安装和使用以及配置健康节点检测
查看>>
Nginx中使用expires指令实现配置浏览器缓存
查看>>
Nginx中实现流量控制(限制给定时间内HTTP请求的数量)示例
查看>>
nginx中配置root和alias的区别
查看>>
nginx主要流程(未完成)
查看>>
Nginx之二:nginx.conf简单配置(参数详解)
查看>>
Nginx从入门到精通
查看>>
Nginx代理websocket配置(解决websocket异常断开连接tcp连接不断问题)
查看>>
Nginx代理初探
查看>>