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 should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height h, and there is a moving platform on each height x from 1 to h.
Each platform is either hidden inside the cliff or moved out. At first, there are n moved out platforms on heights p1,p2,…,pn. The platform on height h is moved out (and the character is initially standing there).
If you character is standing on some moved out platform on height x, then he can pull a special lever, which switches the state of two platforms: on height x and x−1. In other words, the platform you are currently standing on will hide in the cliff and the platform one unit below will change it state: it will hide if it was moved out or move out if it was hidden. In the second case, you will safely land on it. Note that this is the only way to move from one platform to another.
Your character is quite fragile, so it can safely fall from the height no more than 2. In other words falling from the platform x to platform x−2 is okay, but falling from x to x−3 (or lower) is certain death.
Sometimes it's not possible to come down from the cliff, but you can always buy (for donate currency) several magic crystals. Each magic crystal can be used to change the state of any single platform (except platform on height h, which is unaffected by the crystals). After being used, the crystal disappears.
What is the minimum number of magic crystal you need to buy to safely land on the 0 ground level?
思路:
考虑相连的几个位置,判断是否可以从x落到x-2, 否则就使用宝石
代码:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int n, m;
int a[MAXN];
int main()
{
int t;
cin >> t;
while (t--)
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
cin >> a[i];
if (a[m] != 0)
a[++m] = 0;
int cnt = 0, p = a[2]+1;
for (int i = 2; i < m;)
{
p = a[i]+1;
if (a[i + 1] == p - 2)
{
p = a[i + 1];
i += 2;
continue;
}
else
{
cnt++;
p = a[i + 1] + 1;
i++;
continue;
}
}
cout << cnt << endl;
}
return 0;
}
Educational Codeforces Round 74 (Rated for Div. 2) C. Standard Free2play的更多相关文章
- Educational Codeforces Round 74 (Rated for Div. 2) D. AB-string
链接: https://codeforces.com/contest/1238/problem/D 题意: The string t1t2-tk is good if each letter of t ...
- Educational Codeforces Round 74 (Rated for Div. 2) B. Kill 'Em All
链接: https://codeforces.com/contest/1238/problem/B 题意: Ivan plays an old action game called Heretic. ...
- Educational Codeforces Round 74 (Rated for Div. 2) A. Prime Subtraction
链接: https://codeforces.com/contest/1238/problem/A 题意: You are given two integers x and y (it is guar ...
- Educational Codeforces Round 74 (Rated for Div. 2)
传送门 A. Prime Subtraction 判断一下是否相差为\(1\)即可. B. Kill 'Em All 随便搞搞. C. Standard Free2play 题意: 现在有一个高度为\ ...
- Educational Codeforces Round 74 (Rated for Div. 2)【A,B,C【贪心】,D【正难则反的思想】】
A. Prime Subtractiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inpu ...
- Educational Codeforces Round 74 (Rated for Div. 2)补题
慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x> ...
- Educational Codeforces Round 74 (Rated for Div. 2)E(状压DP,降低一个m复杂度做法含有集合思维)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;char s[100005];int pos[ ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- java输入输出 -- Java NIO之选择器
一.简介 前面的文章说了缓冲区,说了通道,本文就来说说 NIO 中另一个重要的实现,即选择器 Selector.在更早的文章中,我简述了几种 IO 模型.如果大家看过之前的文章,并动手写过代码的话.再 ...
- python学习-50 pickle模块
pickle模块 与json方法是一样的 import pickle dic = {'} print(type(dic)) a = pickle.dumps(dic) print(type(a)) f ...
- 13_日期时间、Math、枚举
日期时间.Math.枚举 日期时间 计算机如何表示时间? GMT时间指格林尼治所在地的标准时间,也称为时间协调时(UTC),其他地区的时间都是相对于GMT时间的偏移. 北京位于东八区 = UTC ...
- (一)Maven基础及第一个Maven工程
一.Maven介绍 ANT/Maven/gradle是一个项目管理工具,它包含了一项目对象模型(Project Object Model),一组标准集合,一个项目生命周期(Project Lifecy ...
- Uwl.Admin开源框架(二)
Uwl.Admin开源框架基于QuartzNet定时任务模块的实现 Quartz.NET官网地址:https://www.quartz-scheduler.net/ Quartz.NET文档地址:ht ...
- 关于js异步的一些知识点
1,什么是单线程,和异步有什么关系 单线程-只有一个线程,只能做一件事 单线程的原因:避免DOM 渲染的冲突 浏览器需要渲染DOM JS 可以修改DOM 结构 JS 执行的时候,浏览器DOM 渲染会暂 ...
- 使用的jQuery加载源的优势【问题】
[问题]使用的jQuery加载源的优势? [答案]许多用户在访问其他站点时,已经从谷歌或微软加载过 jQuery.所有结果是,当他们访问您的站点时,会从缓存中加载 jQuery,这样可以减少加载时间. ...
- input 默认提示文字 样式修改(颜色,大小,位置)
input::-webkit-input-placeholder{ color:red; font-size:20px; ...... }
- # 机器学习算法总结-第八天(SKlearn中的kmeans/随机森林)
随机森林 这篇好好看看怎么调参的 我调的最佳参数如下,准确率为0.8428671546929973,细节看上篇文章: alg = RandomForestClassifier(n_estimators ...
- Java架构师告诉你Spring IoC有什么好处呢
前言: 这个问题也一直困惑我很久,毕竟其他语言没有IOC也活的很好. 但是Spring在当时能够一统江湖,跟IOC真的有很大的关系. 在没有IOC的时代,New代表一切,女朋友都是可以New出来的. ...