1 #include<iostream> 2 #include<algorithm> 3 #include<map> 4 using namespace std; 5 6 map<int, int>cnt; 7 8 int main() 9 { 10 int T; 11 cin >> T; 12 while (T--) 13 { 14 cnt.clear(); 15 int n; 16 cin >> n; 17 for (int i = 1; i <= n; i++) 18 { 19 int t; 20 cin >> t; 21 cnt[t]++; 22 } 23 for (int i = n; i >= 1; i--) 24 { 25 cnt[i] += cnt[i + 1]; 26 if (cnt[i] >= i) 27 { 28 cout << i << endl; 29 break; 30 } 31 } 32 } 33 }
原文地址:https://www.cnblogs.com/thjkhdf12/p/11811340.html
时间: 2024-11-05 13:43:42