Source of A 学姐的桌面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int n, a[100010], t;
int main() {
int T;
scanf("%d", &T);
while (T--) {
scanf("%d%d", &n, &t);
for (int i = 0; i < n; ++i)
scanf("%d", &a[i]);
sort(a, a+n);
int l = 0;
int r = n-1;
while (l <= r) {
int mid = (l+r) >> 1;
if (a[mid] < t)
l = mid +1;
else
r = mid -1;
}
double ans = (double)l/(double)n;
ans *= 100;
printf("%.2f", ans);
cout << "%" << endl;
}
return 0;
}

返回