Gym - 102219K :Help The Support Lady(贪心)

http://codeforces.com/gym/102219/problem/K

Nina works as an IT support in a software company and always busy. The biggest issue she is facing is that sometimes she misses some deadlines. In their team the time needed to finish each customer request is estimated based on experience, 1≤x≤105. The moment a request is submitted, she has double of the estimated time to respond to the request, 2x. Meaning if the request A was submitted at 12pm and takes 2 hours to finish, she can wait 2 hours and then work on it for 2 hours and still finish the job on time, by 4

pm and the customer would be satisfied.

Sometimes there is not enough capacity and she has to pick up a lot of requests, and it is expected to miss some deadlines. But she needs your help, to see if arrange correctly what are the maximum requests she can finish before their deadlines.

Let's assume that she has the list of the requests and their deadline immediately as she starts working every day and she doesn't take any break until she is done with all of them.

Input

The first line contains integer m(1≤m≤20). Number of cases.The second line contains integer n(1≤n≤105). Number of the requests.The last line contains nintegers ti (1≤ti≤109), separated by spaces. Estimated time each request should be responded so the customer would be happy.

Output

Print the case number and a single number - the maximum number of satisfied customer for each case.

Example

Input

1
5
15 2 1 5 3

Output

Case #1: 4

Note

If she responds to the request with this order 1, 2, 3, 5, 15, the only customer with the request that requires 5 hours wouldn't be happy.

 

题意分析:

Nina每天工作的时候有n个待完成的工作,每个工作需要x时间来完成,可以在2x之前提交,求最多可以成功提交的工作有多少个。

解题思路:

首先要从时间短的开始做,因为先做时间长的在做短的,短的就有可能超时,所以先按时间排序,

如果一项工作完成之后超过了提交时间,那么这项工作从一开始就不用做,可以结束时间去做其他工作,

所以贪心策略是先判断做这项工作能否在2x之前提交,如果可以,做这项工作,否则,跳过这项工作。

#include <stdio.h>
#include <algorithm>
#define N 100020
using namespace std;
long long  a[N];
int main()
{
	int T, t=0, n;
	scanf("%d", &T);
	while(T--)
	{
		scanf("%d", &n);
		for(int i=0; i<n; i++)
			scanf("%lld", &a[i]);
		sort(a, a+n);
		long long sum=0;
		int ans=0;
		for(int i=0; i<n; i++)
		{
			if(sum<=a[i])
			{
				sum+=a[i];
				ans++;
			}
		}
		printf("Case #%d: %d\n", ++t, ans);
	}
	return 0;
}

 

Python 是一种脚本语言,广泛应用于各类编程和数据分析任务。在机器学习和人工智能领域,Python 也是一门常用的编程语言。基于 Python 的 gym-carracing 是 OpenAI Gym 的一个环境,用于模拟汽车驾驶场景。 这个自动驾驶项目的目标是让计算机通过机器学习算法来自动驾驶模拟的汽车。首先,我们需要安装 gym-carracing 环境及其相关依赖库。然后,我们可以使用强化学习算法,比如深度强化学习算法(如深度 Q 网络),训练一个智能驾驶代理程序。 在训练过程中,代理程序会不断与环境进行交互,获取当前的观测状态,然后根据某种策略选择一个动作作为响应。之后,代理程序会根据环境给予的反馈来调整自己的策略和动作选择,以逐步提升驾驶技能。 在 gym-carracing 环境中,汽车会在一个虚拟的赛道上行驶,玩家需要使用方向键控制汽车的转向,以应对各种道路和弯道情况。在自动驾驶项目中,我们的目标是通过训练智能代理程序,使它能够自动控制汽车,适应不同的道路和驾驶情景,并以高效、安全的方式行驶。 该项目的难点在于设计和实现一个合适的驾驶策略,并通过强化学习算法不断优化代理程序的决策能力。为了取得好的效果,我们可能需要进行大量的训练和参数调整,并结合一些技巧和经验,优化代理程序的性能。 总而言之,Python 和 gym-carracing 提供了一个有趣且实用的平台,可用于开发自动驾驶项目。通过合理的算法和大量的训练,我们希望能够训练出一个高效、智能的驾驶代理程序,使其能够在模拟环境中完成自动驾驶任务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张宜强

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值