日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1017 Queueing at Bank (25 分)_27行代码AC

發(fā)布時間:2024/2/28 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1017 Queueing at Bank (25 分)_27行代码AC 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

立志用最少的代碼做最高效的表達


PAT甲級最優(yōu)題解——>傳送門


Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be served and there is a window available. It is assumed that no window can be occupied by a single customer for more than 1 hour.

Now given the arriving time T and the processing time P of each customer, you are supposed to tell the average waiting time of all the customers.

Input Specification:
Each input file contains one test case. For each case, the first line contains 2 numbers: N (≤10^4) - the total number of customers, and K (≤100) - the number of windows. Then N lines follow, each contains 2 times: HH:MM:SS - the arriving time, and P - the processing time in minutes of a customer. Here HH is in the range [00, 23], MM and SS are both in [00, 59]. It is assumed that no two customers arrives at the same time.

Notice that the bank opens from 08:00 to 17:00. Anyone arrives early will have to wait in line till 08:00, and anyone comes too late (at or after 17:00:01) will not be served nor counted into the average.

Output Specification:
For each test case, print in one line the average waiting time of all the customers, in minutes and accurate up to 1 decimal place.

Sample Input:
7 3
07:55:00 16
17:00:01 2
07:59:59 15
08:01:00 60
08:00:00 30
08:00:02 2
08:03:00 10

Sample Output:
8.2


題意:銀行有N個業(yè)務(wù)窗口,08:00:00點開始辦理業(yè)務(wù),17:01:00準時停止服務(wù)(注意是停止服務(wù),不是停止辦理!!!并且17點來仍然可以服務(wù)。 也就是說如果17點整來一個人辦理一百億年的服務(wù),仍然可以給他辦理。),顧客按順序排隊,求平均等待時間。

明白題意就很好辦了,中規(guī)中矩的寫模擬就行。(方便起見,將循環(huán)拆分成最小的時間片段,也就是秒。)


#include <bits/stdc++.h> using namespace std; typedef struct {int a_time, p_time; }record; int main() {int N, K, cnt = 0, sum = 0;scanf("%d %d", &N, &K);vector<int> time( K, 8 * 60 * 60 );vector<record> rec;for( int i = 0, h, m, s, p; i < N; ++i ) {scanf("%d:%d:%d %d", &h, &m, &s, &p);if( h * 3600 + m * 60 + s <= 17 * 3600 )rec.push_back( { h * 3600 + m * 60 + s, p * 60 } );}sort( rec.begin(), rec.end(), [] ( record a, record b ) { return a.a_time < b.a_time; } );for( int i = 0, min; i < rec.size(); ++i ) {min = 0;for( int j = 0; j < K; ++j )if( time[j] < time[min] ) min = j;if( time[min] > rec[i].a_time ) {sum += time[min] - rec[i].a_time;time[min] += rec[i].p_time;}else time[min] = rec[i].p_time + rec[i].a_time;}printf("%.1f", sum / 60.0 / rec.size() ); }

耗時:


??????——發(fā)現(xiàn)光,追隨光,成為光,發(fā)散光。

總結(jié)

以上是生活随笔為你收集整理的1017 Queueing at Bank (25 分)_27行代码AC的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲一区二区三区在线 | 亚洲国产一二三区 | 视频一区二区在线播放 | 成人毛片100部免费看 | 黄色在线观看av | 欧美性受xxxx黑人xyx性爽 | 国产精品男女视频 | 一区二区蜜桃 | 男女爱爱网站 | 2018狠狠干| 龚玥菲一级淫片 | 国产精品wwww | 欧美一级淫片免费 | 亚洲精品乱码久久久久99 | 亚洲AV无码成人片在线观看 | 亚洲成av人片在线观看无 | 精品久久久一区 | 国产精品第一页在线观看 | 久久人妻少妇嫩草av无码专区 | 亚洲成人高清 | 草草影院在线播放 | 深爱五月激情五月 | 7788色淫网站小说 | 亚洲人性生活视频 | 日韩欧美国产一区二区 | av在线电影观看 | 欧美精品一区二区三区久久久竹菊 | 蜜桃导航-精品导航 | 性欧美久久 | 干爹你真棒插曲免费 | 很黄很污的视频 | 一曲二曲三曲在线观看中文字幕动漫 | 禁欲天堂 | 日本a一级| 黑人玩弄人妻一区二区三区四 | 色网站入口 | 日本女人一区二区三区 | 久久精品2019中文字幕 | 国产婷婷一区二区三区 | 在线观看av片 | 贝利弗山的秘密1985版免费观看 | 日韩欧美激情视频 | 国产aaa级片 | 国产真实乱人偷精品 | 2025中文字幕 | 男人天堂视频在线 | 久久人精品 | 国产福利精品在线观看 | 涩涩视频免费 | 亚洲精品视频播放 | 亚洲精品成人无码熟妇在线 | 97超碰在| 美女被到爽高潮视频 | 国产欧美一区在线观看 | 毛片看| 91精品国产综合久久久蜜臀图片 | 亚洲精品伊人 | 欧美午夜精品一区二区 | 久久精品一本 | 日韩一区二区三区不卡 | mm1313亚洲国产精品无码试看 | 天堂а√在线中文在线 | 99精品人妻国产毛片 | 久久久久国产精品无码免费看 | 做视频| 中文字幕在线有码 | 韩日午夜在线资源一区二区 | 国产精品一品二区三区的使用体验 | 天堂一级片 | 污网站在线观看免费 | 黄色片hd| 黄色av免费观看 | 中文字幕永久在线观看 | 亚洲成av人片在www色猫咪 | 我要爱爱网 | 精品人妻无码一区二区 | 亚洲精品中文字幕成人片 | 可以免费看污视频的网站 | 黄色小视频在线 | 精品无人区无码乱码毛片国产 | 美女国产视频 | 黄频在线免费观看 | 免费在线观看成人 | 男人的天堂99 | 夜夜高潮夜夜爽国产伦精品 | 天堂精品在线 | 第一宅男av导航入口 | 国产成人精品亚洲日本在线观看 | 美女穴穴 | www.五月天com| 91爱爱com| 亚洲色图欧美自拍 | 97免费人妻无码视频 | 男男啪啪网站 | 天天色棕合合合合合合合 | 亚洲欧美乱日韩乱国产 | 在线亚洲+欧美+日本专区 | 黄色三级三级三级三级 | 男人添女人囗交视频 |