链接:

https://codeforces.com/contest/1238/problem/B

题意:

Ivan plays an old action game called Heretic. He's stuck on one of the final levels of this game, so he needs some help with killing the monsters.

The main part of the level is a large corridor (so large and narrow that it can be represented as an infinite coordinate line). The corridor is divided into two parts; let's assume that the point x=0 is where these parts meet.

The right part of the corridor is filled with n monsters — for each monster, its initial coordinate xi is given (and since all monsters are in the right part, every xi is positive).

The left part of the corridor is filled with crusher traps. If some monster enters the left part of the corridor or the origin (so, its current coordinate becomes less than or equal to 0), it gets instantly killed by a trap.

The main weapon Ivan uses to kill the monsters is the Phoenix Rod. It can launch a missile that explodes upon impact, obliterating every monster caught in the explosion and throwing all other monsters away from the epicenter. Formally, suppose that Ivan launches a missile so that it explodes in the point c. Then every monster is either killed by explosion or pushed away. Let some monster's current coordinate be y, then:

if c=y, then the monster is killed;

if y<c, then the monster is pushed r units to the left, so its current coordinate becomes y−r;

if y>c, then the monster is pushed r units to the right, so its current coordinate becomes y+r.

Ivan is going to kill the monsters as follows: choose some integer point d and launch a missile into that point, then wait until it explodes and all the monsters which are pushed to the left part of the corridor are killed by crusher traps, then, if at least one monster is still alive, choose another integer point (probably the one that was already used) and launch a missile there, and so on.

What is the minimum number of missiles Ivan has to launch in order to kill all of the monsters? You may assume that every time Ivan fires the Phoenix Rod, he chooses the impact point optimally.

You have to answer q independent queries.

思路:

模拟, 记录往右移的总长度.挨个判断.

代码:

#include<bits/stdc++.h>
using namespace std; set<int> St;
int n, r; int main()
{
int t;
cin >> t;
while (t--)
{
St.clear();
cin >> n >> r;
int v;
for (int i = 0; i < n; i++)
{
cin >> v;
St.insert(v);
}
int cnt = 0, sum = 0;
while (!St.empty())
{
while (!St.empty() && *St.begin()-sum <= 0)
St.erase(*St.begin()); if (St.empty())
break;
cnt++, sum += r;
St.erase(*St.rbegin());
}
cout << cnt << endl;
} return 0;
}

Educational Codeforces Round 74 (Rated for Div. 2) B. Kill 'Em All的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

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

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

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

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

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

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

  7. 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[ ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Counting Cliques(HDU-5952)【DFS】

    题目链接:https://vjudge.net/problem/HDU-5952 题意:有一张无向图,求结点数量为S的团的数量. 思路:如果不加一点处理直接用DFS必然会超时,因为在搜索过程中会出现遍 ...

  2. Oracle数据库——查询所有用户

    查询数据库所有用户(ALL_USERS)的用户名,用户编号,创建日期 默认应该有36个用户 SELECT * FROM ALL_USERS; 查看ALL_USERS的结构 DESC ALL_USERS ...

  3. Ubuntu截图工具Flameshot

    今天来介绍一款Ubuntu下的截图工具,名叫Flameshot. 安装 Flameshot的安装很简单. 命令行安装 sudo apt-get install flameshot 一条命令搞定! 软件 ...

  4. double check

    http://www.cnblogs.com/limingluzhu/p/5156659.html http://blog.csdn.net/chenchaofuck1/article/details ...

  5. gmpy安装使用方法

    gmpy是一种C编码的Python扩展模块,提供对GMP(或MPIR)多精度算术库的访问.gmpy 1.17是1.x系列的最终版本,没有进一步的更新计划.所有进一步的开发都在2.x系列(也称为gmpy ...

  6. react以组件为中心的代码分割和懒加载

    背景 随着项目越来越复杂,功能够越来越多,JS单个文件就会比较臃肿,js代码拆分显得必不可少. Js文件拆分主要分为按照路由进行js拆分.按照组件进行js拆分. 按照路由拆分:因为本项目请求路径得原因 ...

  7. jacascript CSS样式的脚本化(js)操作

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! 引入CSS有3种方式:行间样式,内联样式和外部链接样式. 在实际工作中,我们使用 javascript 操 ...

  8. [Vue]vue-loader作用

    一.vue文件 vue文件是一个自定义的文件类型,用类HTML语法描述一个vue组件,每个.vue组件包含三种类型的顶级语言快< template>< script>< ...

  9. (一)ORM基础

    一.ORM思想解析 要了解学习Hibernate框架,就不得不提到ORM思想,因为Hibernate就是基于ORM思想的一个产品. 1.1 介绍 广义上,ORM指的是面向对象的对象模型和关系型数据库的 ...

  10. node - path路径

    1.node命令路径与js文件路径 node命令路径为node命令所执行的目录,js文件路径指的是你要运行的js所在的目录. 如上图所示: server.js路径为E:\zyp: node命令路径我们 ...