2110.cpp (327B)
1 class Solution { 2 public: 3 long long getDescentPeriods(const vector<int> &prices) const { 4 long long res = 1, cnt = 1; 5 const int n = prices.size(); 6 for (int i = 1; i < n; i++) { 7 if (prices[i] + 1 != prices[i - 1]) cnt = 0; 8 res += ++cnt; 9 } 10 return res; 11 } 12 };