PAT甲级1014 Waiting in Line (30 分)

该博客讨论了一种模拟银行窗口排队系统的方法,其中客户根据最短队列原则选择窗口,并考虑了每条队伍的最大容量。通过输入每个客户的处理时间和查询,算法能够精确预测客户完成交易的时间。当预测时间超过下午5点时,输出为'Sorry'。源代码实现了这一逻辑,并已通过所有测试用例,强调了关键点如开始时间限制和队伍人数限制的处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原题:

Suppose a bank has NNN windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:

  • The space inside the yellow line in front of each window is enough to contain a line with MMM customers. Hence when all the NNN lines are full, all the customers after (and including) the (NM+1)(NM+1)(NM+1)st one will have to wait in a line behind the yellow line.
  • Each customer will choose the shortest line to wait in when crossing the yellow line. If there are two or more lines with the same length, the customer will always choose the window with the smallest number.
  • CustomeriCustomer_iCustomeri will take TiT_iTi minutes to have his/her transaction processed.
  • The first NNN customers are assumed to be served at 8:00am.

Now given the processing time of each customer, you are supposed to tell the exact time at which a customer has his/her business done.

For example, suppose that a bank has 2 windows and each window may have 2 customers waiting inside the yellow line. There are 5 customers waiting with transactions taking 1, 2, 6, 4 and 3 minutes, respectively. At 08:00 in the morning, customer1customer_1customer1 is served at window1window_1window1 while customer2customer_2customer2 is served at window2window_2window2. Customer3Customer_3Customer3 will wait in front of window1window_1window1 and customer4customer_4customer4 will wait in front of window2window_2window2. Customer5Customer_5Customer5 will wait behind the yellow line.

At 08:01, customer1customer_1customer1 is done and customer5customer_5customer5 enters the line in front of window1window_1window1 since that line seems shorter now. Customer2Customer_2Customer2 will leave at 08:02, customer4customer_4customer4 at 08:06, customer3customer_3customer3 at 08:07, and finally customer5customer_5customer5 at 08:10.

Input Specification:

Each input file contains one test case. Each case starts with a line containing 4 positive integers: NNN (≤20\le 2020, number of windows), MMM (≤10\le 1010, the maximum capacity of each line inside the yellow line), KKK (≤1000\le 10001000, number of customers), and QQQ (≤1000\le 10001000, number of customer queries).

The next line contains KKK positive integers, which are the processing time of the KKK customers.

The last line contains QQQ positive integers, which represent the customers who are asking about the time they can have their transactions done. The customers are numbered from 1 to KKK.

Output Specification:

For each of the QQQ customers, print in one line the time at which his/her transaction is finished, in the format HH:MM where HH is in [08, 17] and MM is in [00, 59]. Note that since the bank is closed everyday after 17:00, for those customers who cannot be served before 17:00, you must output Sorry instead.

Sample Input:

2 2 7 5
1 2 6 4 3 534 2
3 4 5 6 7

Sample Output:

08:07
08:06
08:10
17:00
Sorry
源代码:
#include<iostream>
#include<queue>
using namespace std;
int n, m, k, q;
struct Person{
    int q;
    int st = -1;
    int nt;
    int ft = -1;
}person[1005];
queue<Person> que[21];
int main(){
    cin>>n>>m>>k>>q;
    for(int i = 1; i <= k; i ++){
        cin>>person[i].nt;
        person[i].q = i;
    }
    int tag = 0;
    int num = 1;
    int serverpeople = 0;
    while(tag <= 540){
        for(num; num <= k && serverpeople < m * n; num ++){
            int minque;
            int minlen = 15;
            for(int i = 0; i < n; i ++){
                if(que[i].size() < minlen){
                    minlen = que[i].size();
                    minque = i;
                }
            }
//            if(que[minque].size() <= m){
                que[minque].push(person[num]);
                serverpeople ++;
//            }
        }
        for(int i = 0; i < n; i ++){
            Person p = que[i].front();
            if(person[p.q].st == -1 && tag < 540){
                person[p.q].st = tag;
                person[p.q].ft = tag + person[p.q].nt;
            }
            person[p.q].nt --;
            if(person[p.q].nt == 0){
                que[i].pop();
                serverpeople --;
            }
            /*if(person[p.q].ft > 540){
                que[i].pop();
                person[p.q].ft = -1;
            }*/
        }
        tag ++;
    }
    for(int i = 0; i < q; i ++){
        int wq;
        cin>>wq;
        if(person[wq].ft == -1)
            cout<<"Sorry"<<endl;
        else{
            int hour, min;
            hour = person[wq].ft / 60 + 8;
            min = person[wq].ft % 60;
            if(hour < 10)
                cout<<"0"<<hour<<":";
            else
                cout<<hour<<":";
            if(min < 10)
                cout<<"0"<<min<<endl;
            else
                cout<<min<<endl;
        }
    }
}

已AC:在这里插入图片描述

易失分点:
1.只要开始时间在17点之内即可,结束时间无所谓
2.在每一分钟寻找最短的队伍的同时要判断人数是否超限
3.输出时间记得补0

标题SpringBoot基于Web的图书借阅管理信息系统设计与实现AI更换标题第1章引言介绍图书借阅管理信息系统的研究背景、意义、现状以及论文的研究方法和创新点。1.1研究背景与意义析当前图书借阅管理的需求和SpringBoot技术的应用背景。1.2国内外研究现状概述国内外在图书借阅管理信息系统方面的研究进展。1.3研究方法与创新点介绍本文采用的研究方法和系统设计的创新之处。第2章相关理论技术阐述SpringBoot框架、Web技术和数据库相关理论。2.1SpringBoot框架概述介绍SpringBoot框架的基本概念、特点和核心组件。2.2Web技术基础概述Web技术的发展历程、基本原理和关键技术。2.3数据库技术应用讨论数据库在图书借阅管理信息系统中的作用和选型依据。第3章系统需求析对图书借阅管理信息系统的功能需求、非功能需求进行详细析。3.1功能需求析列举系统应具备的各项功能,如用户登录、图书查询、借阅管理等。3.2非功能需求析阐述系统应满足的性能、安全性、易用性等方面的要求。第4章系统设计详细介绍图书借阅管理信息系统的设计方案和实现过程。4.1系统架构设计给出系统的整体架构,包括前后端离、数据库设计等关键部。4.2功能模块设计具体阐述各个功能模块的设计思路和实现方法,如用户管理模块、图书管理模块等。4.3数据库设计详细介绍数据库的设计过程,包括表结构、字段类型、索引等关键信息。第5章系统实现与测试对图书借阅管理信息系统进行编码实现,并进行详细的测试验证。5.1系统实现介绍系统的具体实现过程,包括关键代码片段、技术难点解决方法等。5.2系统测试给出系统的测试方案、测试用例和测试结果,验证系统的正确性和稳定性。第6章结论与展望总结本文的研究成果,指出存在的问题和未来的研究方向。6.1研究结论概括性地总结本文的研究内容和取得的成果。6.2展望对图书借阅管理
摘 要 基于SpringBoot的电影院售票系统为用户提供了便捷的在线购票体验,覆盖了从注册登录到观影后的评价反馈等各个环节。用户能够通过系统快速浏览和搜索电影信息,包括正在热映及即将上映的作品,并利用选座功能选择心仪的座位进行预订。系统支持多种支付方式如微信、支付宝以及银行卡支付,同时提供积兑换和优惠券领取等功能,增强了用户的购票体验。个人中心允许用户管理订单、收藏喜爱的影片以及查看和使用优惠券,极大地提升了使用的便利性和互动性。客服聊天功能则确保用户在遇到问题时可以即时获得帮助。 后台管理人员,系统同样提供了全面而细致的管理工具来维护日常运营。管理员可以通过后台首页直观地查看销售额统计图,了解票房情况并据此调整策略。电影信息管理模块支持新增、删除及修改电影资料,确保信息的准确与及时更新。用户管理功能使得管理员可以方便地处理用户账号,包括导入导出数据以供析。订单管理模块简化了对不同状态订单的处理流程,提高了工作效率。优惠券管理和弹窗提醒管理功能有助于策划促销活动,吸引更多观众。通过这样的集成化平台,SpringBoot的电影院售票系统不仅优化了用户的购票体验,也加强了影院内部的管理能力,促进了业务的发展和服务质量的提升。 关键词:电影院售票系统;SpringBoot框架;Java技术
内容概要:本文介绍了2025年中国网络安全的十大创新方向,涵盖可信数据空间、AI赋能数据安全、ADR(应用检测与响应)、供应链安全、深度伪造检测、大模型安全评估、合规管理与安全运营深度融合、AI应用防火墙、安全运营智能体、安全威胁检测智能体等。每个创新方向不仅提供了推荐的落地方案和典型厂商,还详细阐述了其核心能力、应用场景、关键挑战及其用户价值。文中特别强调了AI技术在网络安全领域的广泛应用,如AI赋能数据安全、智能体驱动的安全运营等,旨在应对日益复杂的网络威胁,提升企业和政府机构的安全防护能力。 适合人群:从事网络安全、信息技术、数据管理等相关工作的专业人士,尤其是负责企业信息安全、技术架构设计、合规管理的中高层管理人员和技术人员。 使用场景及目标:①帮助企业理解和应对最新的网络安全威胁和技术趋势;②指导企业选择合适的网络安全产品和服务,提升整体安全防护水平;③协助企业构建和完善自身的网络安全管理体系,确保合规运营;④为技术研发人员提供参考,推动技术创新和发展。 其他说明:文章内容详尽,涉及多个技术领域和应用场景,建议读者根据自身需求重点关注相关章节,并结合实际情况进行深入研究和实践。文中提到的多个技术和解决方案已在实际应用中得到了验证,具有较高的参考价值。此外,随着技术的不断发展,文中提及的部技术和方案可能会有所更新或改进,因此建议读者保持关注最新的行业动态和技术进展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值