环形路加油
#include <vector> using namespace std; int selectGasStation(const vector<int> &a, const vector<int> &g) { int total = 0; int sum = 0; int n = g.size(); int index = -1; for(int i=0;i<n;i++) { total += (a[i]-g[i]); sum += (a[i]-g[i]); if(sum<0) { index = i; sum = 0; } } return (total>=0?index+1:-1); }