CCF-CSP练习 期末预测之最佳阈值
CCF 202012-2 期末预测之最佳阈值
题目背景
题目描述
输入格式
输出格式
样例1输入
6
0 0
1 0
1 1
3 1
5 1
7 1
样例1输出
3
样例1解释
样例2输入
8
5 1
5 0
5 0
2 1
3 0
4 0
100000000 1
1 0
样例1输出
100000000
子任务
我的提交
#include<bits/stdc++.h>
using namespace std;
struct classmates{
int y;//安全指数
int re;//result:0挂科、1未挂科
int zql;
}c[100005];
int main()
{
int m,i,j,z=0,max=0;
cin>>m;
for(i=1;i<=m;i++)
{
cin>>c[i].y>>c[i].re;
}
for(i=1;i<=m;i++)
{
for(j=1;j<=m;j++)
{
if((c[j].y<c[i].y&&c[j].re==0)||(c[j].y>=c[i].y&&c[j].re==1))
c[i].zql++;
}
//cout<<c[i].y<<"的正确率为"<<c[i].zql<<endl;
if(z<c[i].zql||(z==c[i].zql&&max<c[i].y))
{
z=c[i].zql;
max=c[i].y;
//cout<<"z和max分别更新为"<<z<<"、"<<max<<endl;
}
}
cout<<max<<endl;
}