leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1701.cpp (469B)


0 class Solution {
1 public:
2 double averageWaitingTime(const vector<vector<int>> &customers) {
3 const int n = customers.size();
4 double time = 0, res = 0;
5 for (int i = 0; i < n; i++) {
6 if (time < customers[i][0])
7 time = customers[i][0];
8 else
9 res += time - customers[i][0];
10 time += customers[i][1];
11 res += customers[i][1];
12 }
13 return res / n;
14 }
15 };