博客
关于我
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/

你可能感兴趣的文章
node.js模拟qq漂流瓶
查看>>
node.js的express框架用法(一)
查看>>
Node.js的交互式解释器(REPL)
查看>>
Node.js的循环与异步问题
查看>>
Node.js高级编程:用Javascript构建可伸缩应用(1)1.1 介绍和安装-安装Node
查看>>
nodejs + socket.io 同时使用http 和 https
查看>>
NodeJS @kubernetes/client-node连接到kubernetes集群的方法
查看>>
NodeJS API简介
查看>>
Nodejs express 获取url参数,post参数的三种方式
查看>>
nodejs http小爬虫
查看>>
nodejs libararies
查看>>
vue3+element-plus 项目中 el-switch 刷新后自动触发change?坑就藏在这里!
查看>>
nodejs npm常用命令
查看>>
nodejs npm常用命令
查看>>
Nodejs process.nextTick() 使用详解
查看>>
NodeJS yarn 或 npm如何切换淘宝或国外镜像源
查看>>
nodejs 中间件理解
查看>>
nodejs 创建HTTP服务器详解
查看>>
nodejs 发起 GET 请求示例和 POST 请求示例
查看>>
NodeJS 导入导出模块的方法( 代码演示 )
查看>>