PTA Queueing at Bank

链接

https://pintia.cn/problem-sets/994805342720868352/problems/994805491530579968

题解

这题看起来简单
其实很坑啊
想想这样的情况:有1000个人,全都是在8:00:00来的,每个人要花一个小时处理,就只有一个窗口
这样肯定要10000个小时来处理全部的人,虽然银行仅仅开门9个小时,但是缺花10000小时!
出题人脑洞真大

代码

#include <bits/stdc++.h>
#define maxn 10010
#define cl(x) memset(x,0,sizeof(x))
#define ll long long
using namespace std;
ll N, K, res[maxn], ans, tot;
pair<ll,ll> cus[maxn];
ll read(ll x=0)
{
	ll c, f=1;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+c-48;
	return f*x;
}
void init()
{
	ll i;
	N=read(), K=read();
	for(i=1;i<=N;i++)
	{
		cus[i].first=read()*3600+read()*60+read(), cus[i].second=read()*60;
		if(cus[i].first<=61200)cus[++tot]=cus[i];
	}
	N=tot;
	sort(cus+1,cus+N+1);
}
void work()
{
	ll i, j, k, p=1;
	for(i=28800;i<=36028800 and p<=N;i++)
	{
		for(j=1;j<=K;j++)
		{
			if(res[j]==0)
			{
				if(cus[p].first<=i and p<=N)
				{
					res[j]=cus[p].second-1;
					ans+=i-cus[p].first;
					p++;
				}
			}
			else res[j]--;
		}
	}
	if(p==1)printf("0.0");
	printf("%.1lf",ans/60.0/N);
}
int main()
{
	init();
	work();
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值