传送门

显然从左到右考虑每个要删除的数

维护一个 $cnt$ 表示之前已经删除了 $cnt$ 个数,那么当前所有要删除数的实际位置就要减去 $cnt$

直接暴力枚举哪些数在最左边一个块然后一起删除

每个数删除一次复杂度 $O(n)$

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline ll read()
{
ll x=,f=; char ch=getchar();
while(ch<''||ch>'') { if(ch=='-') f=-; ch=getchar(); }
while(ch>=''&&ch<='') { x=(x<<)+(x<<)+(ch^); ch=getchar(); }
return x*f;
}
const int N=2e5+;
ll m,K,ans;
ll n,p[N];
int main()
{
n=read(),m=read(),K=read();
for(int i=;i<=m;i++) p[i]=read();
ll cnt=;
for(int i=;i<=m;i++)
{
ll r=i; while(r<m && ((p[r+]-cnt-)/K==(p[i]-cnt-)/K) ) r++;
cnt+=r-i+; i=r; ans++;
}
printf("%lld\n",ans);
return ;
}

Codeforces 1190A. Tokitsukaze and Discard Items的更多相关文章

  1. [模拟] Codeforces - 1191C - Tokitsukaze and Discard Items

    Tokitsukaze and Discard Items time limit per test 1 second memory limit per test 256 megabytes input ...

  2. Codeforces - 1191C - Tokitsukaze and Discard Items - 模拟

    https://codeforces.com/contest/1191/problem/C 一开始想象了一下,既然每次删除都是往前面靠,那么好像就是页数*页容量+空位数=最多容纳到的坐标. 至于为什么 ...

  3. [Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论)

    [Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论) 题面 有n堆石子,两个人轮流取石子,一次只能从某堆里取一颗.如果某个人取的时候已经没有石 ...

  4. Codeforces 1190C. Tokitsukaze and Duel

    传送门 注意到后手可以模仿先手的操作,那么如果一回合之内没法决定胜负则一定 $\text{once again!}$ 考虑如何判断一回合内能否决定胜负 首先如果最左边和最右的 $0$ 或 $1$ 距离 ...

  5. Codeforces - 1191E - Tokitsukaze and Duel - 博弈论 - 尺取

    https://codeforc.es/contest/1191/problem/E 参考自:http://www.mamicode.com/info-detail-2726030.html 和官方题 ...

  6. Codeforces - 1191F - Tokitsukaze and Strange Rectangle - 组合数学 - 扫描线

    https://codeforces.com/contest/1191/problem/F 看了一下题解的思路,感觉除了最后一段以外没什么启发. 首先离散化x加快速度,免得搞多一个log.其实y不需要 ...

  7. Codeforces - 1191B - Tokitsukaze and Mahjong - 模拟

    https://codeforces.com/contest/1191/problem/B 小心坎张听的情况. #include<bits/stdc++.h> using namespac ...

  8. Codeforces 1190C Tokitsukaze and Duel game

    题意:有一个长为n的01串,两个人轮流操作,每个人可以把某个长度为m的区间变成相同颜色,谁在操作后整个串颜色相同就赢了.问最后是谁赢?(有可能平局) 思路:容易发现,如果第一个人不能一击必胜,那么他就 ...

  9. Codeforces 1191B Tokitsukaze and Mahjong

    题目链接:http://codeforces.com/problemset/problem/1191/B 题意:类似于麻将,三个一样花色一样数字的,或者三个同花顺就赢了,新抽的能当任何类型,问至少几个 ...

随机推荐

  1. RTS打卡计划第四周

    Algorithms: https://leetcode-cn.com/problems/subarray-sum-equals-k/comments/ 此问题开始考虑空间换时间,结果完全不用空间,不 ...

  2. Nginx-rtmp点播之complex handshake

    1. 点播的配置 假设配置文件 nginx.conf 中对 rtmp 配置如下: # 创建的子进程数 worker_processes 1; #error_log logs/error.log; er ...

  3. 小程序支持npm包

  4. Ansible 快速安装配置,常用模块

    Ansible是一个轻量级的工具,基于python语言实现,通过python中的paramiko来连接并管理机器, 功能强大(YAML,PlayBook,模块化功能),不需要安装客户端, 通过ssh连 ...

  5. html添加注释怎么弄?

    HTML 注释: <!--这是一段注释.注释不会在浏览器中显示.--> 这是一段普通的段落. 快捷键: 我用的是 Notpad++ 添加行注释 Ctrl+K 取消行注释 Ctrl+Shif ...

  6. LC 962. Maximum Width Ramp

    Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j].  The ...

  7. 五十:数据库之Flask-Script详解

    使用flask-script可以实现自定义命令来操作flask,如:可以通过命令来跑一个开发版本的服务器.设置数据库.定时任务等安装:pip install flask-script 命令的添加方式1 ...

  8. kubernetes系列:(三)、helm的安装和使用

    一.helm简介 kubernetes : 解决了容器维护的难题,通过yaml编写,比如deployment,job,statefulset.configmap等等,通过控制循环,让容器镜像便于管理, ...

  9. iOS杂记-告警清理

    NS_ASSUME_NONNULL_BEGIN @interface Robot : NSObject @property (copy,readonly) NSString *name; - (nul ...

  10. java.lang.ClassNotFoundException: org.apache.commons.dbutils.QueryRunner

    七月 28, 2017 11:06:33 下午 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() fo ...