Update
This commit is contained in:
@@ -65,7 +65,7 @@ public:
|
||||
for (int i = 0; i < cost.size(); i++) {
|
||||
int rest = gas[i] - cost[i]; // 记录剩余油量
|
||||
int index = (i + 1) % cost.size();
|
||||
while (rest > 0 && index != i) { // 模拟以i为起点行驶一圈
|
||||
while (rest > 0 && index != i) { // 模拟以i为起点行驶一圈(如果有rest==0,那么答案就不唯一了)
|
||||
rest += gas[index] - cost[index];
|
||||
index = (index + 1) % cost.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user