首页 > 编程知识 正文

out of memory at line:2,w391 blank line at end of file

时间:2023-05-04 00:37:42 阅读:11623 作者:4570

1014 .等待在线(30 )时间限制400毫秒

内存限制65536 kB

代码长度限制16000 B

问题判定程序Standard作者CHEN,yesupposeabankhasnwindowsopenforservice.thereisayellowlineinfrontofthewindowswhichdevidesthewaitingarrare

thespaceinsidetheyellowlineinfrontofeachwindowisenoughtocontainalinewithmcustomers.hencewhenallthenlinesarefull,althecusttous stonewillhavetowaitinalinebehindtheyellowline.eachcustomerwillchoosetheshortestlinetowaitinwhencrossingtheyellowline.ifthe ameLength, thecustomerwillalwayschoosethewindowwiththesmallestnumber.customer [ I ] will taket [ I ] minutestohavehis/hertransactionprocessed.thefirstncustomersareassumedtobeservedat 8336000 am.nowgiventheprocessingtimeofeachcustomer,youarerered

For example,supposethatabankhas2windowsandeachwindowmayhave 2客户swaitinginsidetheyellowline.there are 5客户swaitingwitte 4and3minutes,respectively.at 08336000 in the morning,customer1isservedatwindow1while customer2isservedatwindow2. customer3window

At 08:01, customer1isdoneandcustomer5entersthelineinfrontofwindow1sincethatlineseemsshorternow.customer2willleaveat 0833333331 customer4aater 4

输入输出

n-top:0px; margin-bottom:1.5 t-family:inherit; vertical-align:baseline"> Each input file contains one test case. Each case starts with a line containing 4 positive integers: N (<=20, number of windows), M (<=10, the maximum capacity of each line inside the yellow line), K (<=1000, number of customers), and Q (<=1000, number of customer queries).

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

The last line contains Q 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 K.

Output

For each of the Q 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 51 2 6 4 3 534 23 4 5 6 7 Sample Output 08:0708:0608:1017:00Sorry 原题链接:

https://www.patest.cn/contests/pat-a-practise/1014https://www.nowcoder.com/questionTerminal/c8803208356c40ccabc234e8fca6625b思路:坑点:17点还没有办完的事情是可以继续办的,而17点还没有开始的任务就不能办了变量需要在主函数外定义(不懂?)CODE: #include<iostream>#include<queue>#include<cstring>#include<string>using namespace std;typedef struct S{ int co; int k;}se;queue<S> lst[22];int cost[1010];int re[1010];string qxdsb1010];int main(){ int n,m,k,q; cin>>n>>m>>k>>q; for (int i=1;i<=k;i++) cin>>cost[i]; int no=0; int num; for (int i=1;i<=min(m*n,k);i++) { S t; t.co=cost[i]; t.k=i; lst[no].push(t); no++; no%=n; num=i; } int nn=0; for (int j=1;j<=540;j++) { //cout<<j<<endl; for (int i=0;i<n;i++) { if (lst[i].empty()) continue; lst[i].front().co--; if (lst[i].front().co==0) { re[lst[i].front().k]=j; lst[i].pop(); if (num==k) continue; else { num++; S t; t.co=cost[num]; t.k=num; lst[i].push(t); } } } } for (int i=0;i<n;i++) { int sss=540; if (!lst[i].empty()) { if (lst[i].front().co!=cost[lst[i].front().k]) { re[lst[i].front().k]=sss+lst[i].front().co; lst[i].pop(); } } } for (int i=0;i<n;i++) { if (!lst[i].empty()) { while (!lst[i].empty()) { re[lst[i].front().k]=-1; lst[i].pop(); } } } for (int i=num+1;i<=k;i++) { re[i]=-1; } for (int i=1;i<=k;i++) { //cout<<re[i]<<endl; qxdsbi]=""; if (re[i]==-1) { qxdsbi]="Sorry"; continue; } int s1=re[i]/60+8; int s2=re[i]%60; qxdsbi]+=('0'+s1/10); qxdsbi]+=('0'+s1%10); qxdsbi]+=":"; qxdsbi]+=('0'+s2/10); qxdsbi]+=('0'+s2%10); } for (int i=0;i<q;i++) { int se; cin>>se; cout<<qxdsbse]<<endl; } return 0;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。