期末预测之最佳阈值c语言 70分超时
#include <stdio.h>
int main()
{
int n,i,m,s=0,jieguo=0;
int y[100000],result[100000];
scanf("%d",&n);
typedef struct Pair
{
int yuzhi;
int count;
}Pairtoo;
for(i=0;i<n;i++){
scanf("%d %d",&y[i],&result[i]);
};
Pairtoo R[100000];
for(i=0;i<n;i++){
R[i].count=0;
int standard=y[i];
R[i].yuzhi=y[i];
for(m=0;m<n;m++){
if(standard>y[m]&&result[m]==0)
R[i].count+=1;
if(standard<=y[m]&&result[m]==1)
R[i].count+=1;
}
}
for(i=0;i<n;i++){
printf("%d %d \n",R[i].yuzhi,R[i].count);
if(R[i].count>s){
s=R[i].count;
jieguo=R[i].yuzhi;
};
if(R[i].count==s){
s=R[i].count;
if(R[i].yuzhi>jieguo)
jieguo=R[i].yuzhi;
};
};
printf("结果:%d",jieguo);
return 0;
}