typedef pair<int, int> PAIR;
struct CmpByValue {
bool operator()(const PAIR& lhs, const PAIR& rhs) {
return lhs.second < rhs.second;
}
};
map<int, int> mp;
for(int i=0; i<gas.size(); i++)
mp[i] = gas[i] - cost[i];
vector<PAIR> v(mp.begin(), mp.end());
sort(v.begin(), v.end(), CmpByValue());