在 C++ 中考虑这个片段
vector<pair<int, vector<long long int>>> strengthVector;
// sorting
for (auto x : strengthVector) {
sort(x.second.begin() + 1, x.second.end(), greater<long long int>());
}
// calculate prefix sum
for (auto x : strengthVector) {
for (j = 1; j < x.second.size(); j++) {
x.second[j] += x.second[j - 1];
}
}
我想用每一对对向量进行排序。我已经尝试过按照以下方式进行操作。但是当我出于调试目的打印这些值时,它表明上述两个操作都没有发生。
在 vscode 中调试代码时,出现以下错误__for_begin: <error reading variable: Cannot access memory at address 0x0>{_M_current = 0x7fffffffda90} 。
我不知道这意味着什么。请赐教。