A - Easy $h$-index
后缀扫一下
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 #define ll long long 5 #define N 200010 6 7 int n; 8 ll arr[N]; 9 10 inline int work() 11 { 12 ll sum = 0; 13 for (int i = n; i >= 0; --i) 14 { 15 sum += arr[i]; 16 if (sum >= i) return i; 17 } 18 return 0; 19 } 20 21 int main() 22 { 23 while (scanf("%d", &n) != EOF) 24 { 25 for (int i = 0; i <= n; ++i) scanf("%lld", arr + i); 26 printf("%d\n", work()); 27 } 28 return 0; 29 }