多彩编程 多彩编程MZPH · CODE BLOG
ARTICLE DETAIL

文章详情

深耕前端与后端开发技术的一线实战笔记与踩坑复盘。

leetcode 耗时100 1701. 平均等待时间

leetcode 耗时100 1701. 平均等待时间 Problem: 1701. 平均等待时间对每个顾客拿到上一个顾客的结束时间计算出当前顾客的结束时间计算等待时间累加即可的耗时100Codeclass Solution { public: double averageWaitingTime(vectorvectorint customers) { int n customers.size(), now customers[0][0]; int need customers[0][1], a, c; int end now need; long long wait need; for(int i 1; i n; i) { now end; a customers[i][0]; if(now a) now a; need customers[i][1]; end now need; wait end - a; } return wait / (double)n; } };
返回列表