struct Data { int num; int index; }; bool cmp(const Data &a,const Data &b) { if (a.num == b.num) return a.index < b.index; return a.num < b.num; } int main() { int n = 0; cin >> n; vector<Data> array(n); for (int i = 0; i < n; ++i) { cin >> array[i].num;; array[i].index = i; } sort(array.begin(), array.end(), cmp); int ans = 1; int temp = array[0].index; for (int i = 1; i < n; ++i) { if (array[i].index >= temp){ ++ans; temp = array[i].index; } } cout << ans << endl; }合唱团这样写也可行吧