传送门

题目别看错了,好像挺多人都读错了...

然后显然可以贪心,只有在需要用 $\text{magic crystals}$ 的时候才用

那么直接模拟即可

如果初始相邻两个突出的平台高度不连续那么我们显然可以直接从上面一步步操作到达下面的平台的上面一个位置

此时考虑如果我们直接操作,那么下面那个平台(设为 $x$)就会缩起来,然后就会掉到更下面的平台(设为 $y$)

如果当前和更下面的平台 $y$ 高度超过 $2$ 了,那么为了不摔死只能用一次 $\text{magic crystals}$

并且用在 $x$ 位置和用在 $x$ 下面一个位置(不是平台)都是一样的,那么直接用在 $x$ 位置就好了

如果和 $y$ 高度不超过 $2$ ,那么我们显然直接操作然后落到 $y$ 即可

这样一定是最优的,直接按着思路模拟,注意细节

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
int 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+;
int Q,n,m,a[N];
int main()
{
Q=read();
while(Q--)
{
n=read(),m=read();
for(int i=;i<=m;i++) a[i]=read();
int ans=;
for(int i=;i<=m;i++)
{
if(n<=a[i]) continue;
if(n!=a[i]+) n=a[i]+;
if(i<m)
{
if(a[i+]==a[i]-) n=a[i+];
else ans++,n=a[i];
continue;
}
if(n>) ans++;
break;
}
printf("%d\n",ans);
}
return ;
}

Codeforces 1238C. Standard Free2play的更多相关文章

  1. Educational Codeforces Round 74 (Rated for Div. 2) C. Standard Free2play

    链接: https://codeforces.com/contest/1238/problem/C 题意: You are playing a game where your character sh ...

  2. C. Standard Free2play --div

    https://codeforces.com/contest/1238/problem/C 题意:下台阶的时候只有一种方式,拉动当前台阶x的 level,然后当前的台阶关闭,调到下边的台阶x-1,如果 ...

  3. CodeForces 1238C(思维+贪心)

    题意 https://vjudge.net/problem/CodeForces-1238C 您现在正在玩一个游戏,您初始在一个高度 h 的悬崖 悬崖沿壁高度为 1-h 的这些位置均有平台,平台有两种 ...

  4. CF-1238 C.Standard Free2play

    题目大意: 有一个墙,高度为h,在每一个高度处都有一个踏板,有的踏板是隐藏着的,有的是伸出来的,小人站在h高度处(题目保证h高度处的踏板一定是伸出来的),这个小人每站到一个踏板上,就可以点一个开关,将 ...

  5. Educational Codeforces Round 74

    目录 Contest Info Solutions A. Prime Subtraction B. Kill 'Em All C. Standard Free2play D. AB-string E. ...

  6. Educational Codeforces Round 74 (Rated for Div. 2)

    传送门 A. Prime Subtraction 判断一下是否相差为\(1\)即可. B. Kill 'Em All 随便搞搞. C. Standard Free2play 题意: 现在有一个高度为\ ...

  7. Educational Codeforces Round 74 (Rated for Div. 2)【A,B,C【贪心】,D【正难则反的思想】】

    A. Prime Subtractiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inpu ...

  8. Educational Codeforces Round 74 (Rated for Div. 2)补题

    慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x> ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. VMware Workstation 与 Device/Credential Guard 不兼容

    之前在本机搭建Docker for Windows的时候,启用了win10自带的虚拟Hyper-V,但是win10的虚拟与VMware Workstation的虚拟有冲突,运行VMware Works ...

  2. 解决Powershell中不能运行脚本问题

    问题: powershell中不能执行脚本,提示‘because running scripts is disabled on this system’ 原因: powershell中默认的execu ...

  3. 用gcov来检查Qt C++程序的代码覆盖率

      最近才发现MinGW里面包含一个叫做gcov的工具,可以用来检查你的程序运行时调用了哪些代码,同时显示代码行被调用的次数.这个功能在代码的覆盖率和性能调优方便都能用上. 我的运行环境 Window ...

  4. Python 生成随机数函数和加密函数(MD5)

    内容来自debugtalk import hashlib import random import string def gen_random_string(str_len): '''生成指定长度的随 ...

  5. java调用exe,及调用bat不成功的解决办法

    开门见山的说,文件目录如下 想调用123.exe,但是尝试了几次调用不到,然后写了个bat.初始内容如下 @echo off D: cd test "123.exe" 双击可以运行 ...

  6. LC 835. Image Overlap

    Two images A and B are given, represented as binary, square matrices of the same size.  (A binary ma ...

  7. React Native真机红屏报错总结

    一.run-android报错:unable to load script from assets 'index.android.bundl' 解决: 1.进入\android\app\src\mai ...

  8. Hander创建消息

    每一个消息都需要被指定的Handler处理,通过Handler创建消息便可以完成此功能.Android消息机制中引入了消息池.Handler创建消息时首先查询消息池中是否有消息存在,如果有直接从消息池 ...

  9. File Zilla连接Ubuntu 失败

    一.SFTP方式连接失败 站点配置 连接失败 二.FTP连接方式失败 站点配置 连接失败

  10. Redis 集群部署

    一.下载所需软件包 redis wget http://download.redis.io/releases/redis-4.0.6.tar.gz ruby wget https://cache.ru ...