题目如下:

One day, Ahmed_Hossam went to Hemose and said "Let's solve a gym contest!". Hemose didn't want to do that, as he was playing Valorant, so he came up with a problem and told it to Ahmed to distract him. Sadly, Ahmed can't solve it... Could you help him?

There is an Agent in Valorant, and he has n

weapons. The i-th weapon has a damage value ai, and the Agent will face an enemy whose health value is H

.

The Agent will perform one or more moves until the enemy dies.

In one move, he will choose a weapon and decrease the enemy's health by its damage value. The enemy will die when his health will become less than or equal to 0

. However, not everything is so easy: the Agent can't choose the same weapon for 2

times in a row.

What is the minimum number of times that the Agent will need to use the weapons to kill the enemy?

Input

Each test contains multiple test cases. The first line contains the number of test cases t

(1≤t≤105)

. Description of the test cases follows.

The first line of each test case contains two integers n

and H (2≤n≤103,1≤H≤109)

— the number of available weapons and the initial health value of the enemy.

The second line of each test case contains n

integers a1,a2,…,an (1≤ai≤109)

— the damage values of the weapons.

It's guaranteed that the sum of n

over all test cases doesn't exceed 2⋅105

.

Output

For each test case, print a single integer — the minimum number of times that the Agent will have to use the weapons to kill the enemy.

Example

Input

3
2 4
3 7
2 6
4 2
3 11
2 1 7

Output

1
2
3

Note

In the first test case, the Agent can use the second weapon, making health value of the enemy equal to 4−7=−3

. −3≤0, so the enemy is dead, and using weapon 1

time was enough.

In the second test case, the Agent can use the first weapon first, and then the second one. After this, the health of enemy will drop to 6−4−2=0

, meaning he would be killed after using weapons 2

times.

In the third test case, the Agent can use the weapons in order (third, first, third), decreasing the health value of enemy to 11−7−2−7=−5

after using the weapons 3 times. Note that we can't kill the enemy by using the third weapon twice, as even though 11−7−7<0

, it's not allowed to use the same weapon twice in a row.

AC代码如下:

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int s[1010];
int main()
{int t,i;scanf("%d", &t);long long num, hp;long long max1 = 0, max2 = 0;while (t--){memset(s, 0, sizeof s);scanf("%lld %lld", &num, &hp);int tmp;for (i = 1; i <= num; i++){scanf("%d", &tmp);s[i] = tmp;}sort(s+1 , s + 1 + num);max1 = s[num];max2 = s[num - 1];//攻击模块long long x = max1 + max2;long long y = hp / x;hp -= y * x;long long count = y * 2;if (hp > 0){if (hp - max1 > 0)count += 2;else{count++;}}printf("%lld\n", count);}return 0;
}

代码解析:

问题的核心:找到最大与第二大的攻击力

在这里直接使用C++中的sort,可以简洁并快速的找到最大与第二大的值。

注意!!!——————》如果你也像我一样单纯的循环(-A  -B;再判断的话)是一定T的,可以再看一眼题目的数据,你应该就可以理解T的原因了!

所以在这里要用    ——————》除(具体看上文的代码)

ps:这个题虽然思维难度上不大,但想A也不容易,一些细节要处理得当才可以!

开学的第二天,我感觉ACM的路越来越近,我一定会加油努力的!!!

A. Gamer Hemose相关推荐

  1. Codeforces Round #746 (Div. 2)

    Codeforces Round #746 (Div. 2) 题号 题目 难度 A Gamer Hemose B Hemose Shopping C Bakry and Partitioning D ...

  2. codeforces:ProblemMset

    最近一个月在codeforces上做的题(做个记录) 后面太多了就不把代码一一放出了,只放置了链接,可根据链接找到提交的代码. 最小子矩阵 #include <iostream> #inc ...

  3. CF1592D Hemose in ICPC ?

    CF1592D Hemose in ICPC ? 题意: 给你一棵n个节点的树,定义dis(a,b)=a,b两点之间路径的gcd的最大值 最多可以询问12次,每次询问给出一个点集合,系统返回当前点集的 ...

  4. 影驰GAMER RGB DDR5-5600评测

    影驰 GAMER RGB DDR5内存,和12代酷睿同步上市,面向主流玩家群体. 这款内存在设计上非常个性,外壳采用了红蓝撞色风格.积木元素设计,顶部的LED光带具有凸起阵列,预留的积木孔位,可适配市 ...

  5. rpg游戏发展史计算机网络,PC Gamer盘点史上最经典RPG游戏TOP15

    RPG角色演类游戏往往能带给玩家史诗般的剧情和难忘的战斗体验,今天外媒PC Gamer盘点了史上最经典RPG游戏TOP15,让我们一起来看看吧! 第 2 页 史上最经典15大RPG 2 6.<质 ...

  6. 华硕主板B85-PRO GAMER关机后鼠标、键盘仍亮着问题的解决办法

    子丰最近入手了华硕B85-PRO GAMER,但是装上了之后,发现关机之后,鼠标和键盘还是亮着的.这其实就说明了USB还处于通电状态.而且关机后主板上的音频那一块的音频灯也是亮着的. 此方法应该也是适 ...

  7. 主板噪音测试软件,华硕B85-Pro Gamer主板测试:SupremeFX音效听感

    华硕B85-Pro Gamer主板测试:SupremeFX音效听感 去年的8系主板上,多家主板厂商不约而同地在主板音效上做起了文章,其中华硕主推的技术是SupremeFX,具体的音质好坏不说,光是Su ...

  8. 3168ngw网卡_无线+千兆有线双网卡!影驰B360 GAMER评测:千元内最具性价比的RGB主板...

    一.前言:搭载无线和有线双网卡 影驰B360 GAMER RGB主板上市 对于没有超频需求的玩家来说,选购i7-8700这样的顶级处理器搭配B360主板是是非常实用的选择.首先是i7-8700处理器默 ...

  9. 2547.Hemose购物(思维)

    题干 Hemose 有一个 n 个整数的数组 a . 他希望 Samez 以非降序对数组进行排序.由于这对 Samez 来说太简单了,因此 Hemose 允许 Samez 仅使用以下操作: 选择指数i ...

最新文章

  1. 最强 NLP 预训练模型库 PyTorch-Transformers 正式开源:支持 6 个预训练框架,27 个预训练模型...
  2. 网络流Dinic cur当前弧优化
  3. Mac环境下mysql安装以及登录
  4. 【Groovy】Groovy 方法调用 ( Groovy 构造函数中为成员赋值 | Groovy 函数的参数传递与键值对参数 | 完整代码示例 )
  5. php用Simple Excel导出xls
  6. Cocos2d-x 3.0final 终结者系列教程03-源代码文件夹说明
  7. c#操作word表格
  8. 命名时取代基优先顺序_【选修五】高中化学重难点知识:有机物的命名方法
  9. oracle ora 00283,【案例】Oracle报错ORA-16433非归档丢失redo无法启动的恢复过程
  10. 2021儋州市民族中学高考成绩查询,海南2021高考成绩排名查询,海南高考个人成绩排名如何查询...
  11. 你知道怎么解决DB读写分离,导致数据不一致问题吗?
  12. Android 第一行代码(第2版).pdf 网盘
  13. 微信小程序轮播图(详细)
  14. UWB定位技术原理图解
  15. 侯晓迪:全身心的投入,吃住都在实验室
  16. 金山打字游戏c语言代码,一天练习一个小C/C++程序(一) 控制台版“金山打字”游戏...
  17. PostgreSQL递归查询(从子到父、从父到子)
  18. python导出百万数据到excel_使用python将大量数据导出到Excel中的小技巧分享
  19. 基于FPGA的火焰识别系统开发——简化版
  20. 手机5g什么时候普及_5G 网络什么时候普及,现在购买 4G 手机划算吗?

热门文章

  1. python数据库连接代码_python 连接各类主流数据库的实例代码
  2. centos7搭建easy-mock服务
  3. Mybatis理解与入门步骤
  4. 微信小程序入门二:底部导航tabBar
  5. 【Java】四种方法复制视频文件比较
  6. js实现点击按钮复制文本功能
  7. java 调试_我最喜欢的Java调试技术
  8. u8薪资管理_用友U8习题集
  9. Python操作Excel最好选择什么模块?
  10. 介绍一种 Python 更方便的爬虫代理池实现方案