解题思路:注意一下可能空置和一定空置两个是互斥的,不能同时满足,所以要从可能空置的里面减去一定空置的
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,check,sum,day;
double may=0,must=0,e,eday;
cin>>n>>e>>check;
for(int i=1;i<=n;i++){
cin>>day;
sum=0;
for(int j=1;j<=day;j++){
cin>>eday;
if(eday<e)
sum++;
}
if(sum>day/2)
may++;
if(sum>day/2&&day>check)
must++;
}
printf("%.1lf%% ",((may-must)/n)*100);
printf("%.1lf%%",((must)/n)*100);
}
运行结果: