文章目录 题意思路代码 题意 题目链接 思路 设备数+1,time+1 代码 class Solution { public: int countTestedDevices(vector<int>& batteryPercentages) { int time = 0; int ans = 0; for (auto &i:batteryPercentages) { if (i - time > 0) { time++; ans++; } } return ans; } };