PAT_A1117#Eddington Number
Source:
Description:
Input Specification:
Output Specification:
Sample Input:10 6 7 6 9 3 10 8 2 7 8 Sample Output:6 Keys:
Code:1 /* 2 Data: 2019-07-19 18:27:10 3 Problem: PAT_A1117#Eddington Number 4 AC: 13:54 5 6 题目大意: 7 E数定义:E天之中,骑行米数超过E的最大天数 8 9 基本思路: 10 从大到小排序,找到最大的i,使A[i]>i 11 */ 12 13 #include<cstdio> 14 #include<functional> 15 #include<algorithm> 16 using namespace std; 17 const int M=1e5+10; 18 int e[M]; 19 20 int main() 21 { 22 #ifdef ONLINE_JUDGE 23 #else 24 freopen("Test.txt","r",stdin); 25 #endif 26 27 int n,pos; 28 scanf("%d",&n); 29 for(int i=1; i<=n; i++) 30 scanf("%d",&e[i]); 31 sort(e+1,e+n+1,greater<int>()); 32 for(pos=1; pos<=n; pos++) 33 if(e[pos] <= pos) 34 break; 35 if(pos==n && e[n]>n) 36 printf("%d",pos); 37 else 38 printf("%d",pos-1); 39 40 return 0; 41 } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |