排序 pat1117

#include<stdio.h>
#include<algorithm>
using namespace std;

const int maxv = 1e5 +10;
int n;
int num[maxv];
bool cmp(int a, int b){
       return a> b;
}


int main(){
       scanf("%d",&n);
       int i;
       for(i = 0 ; i < n; i++){
              scanf("%d", &num[i]);
       }
       sort(num, num + n,cmp);

       for( i = 0 ; i < n; i++){
              if(num[i] <= i+1){
                     break;
              }
       }
       printf("%d\n",i);
       return 0;
}







 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章