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)


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