1060 爱丁顿数 (25分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805269312159744
1 #include <iostream> 2 #include <cmath> 3 #include <algorithm> 4 #include <cstring> 5 #include <string> 6 #include <cstdio> 7 #include <vector> 8 using namespace std; 9 int main() 10 { 11 int n,temp,max=0,j; 12 cin>>n; 13 vector<int>vec(n); 14 for(int i=0;i<n;i++) cin>>vec[i]; 15 sort(vec.begin(),vec.end()); 16 for(int i=0;i<vec.size();i++) 17 if(vec[i]>n-i) { 18 cout<<n-i<<endl; 19 return 0; 20 } 21 cout<<0<<endl; 22 return 0; 23 }
参考https://blog.csdn.net/weixin_42582136/article/details/89353469