C++的福音看到这个题目就想到直接用set来做set:所有元素都会在插入时自动被排序 set和multiset区别: set不允许容器中有重复的元素 multiset允许容器中有重复的元素 AC代码 #include<iostream> #include<set> using namespace std; int n; set<int> m; int main(){ cin>>n; while(n--){ int x; cin>>x; m.insert(x); ...