- 分数线划定
求各位大佬帮我看一下,蒟蒻哪里错了, 点击查看
- 2024-10-15 18:26:22 @
只得了90分T_T
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
struct ss
{
int xuehao;
int fenshu;
};
bool pai(ss a,ss b)
{
if(a.fenshu > b.fenshu)
{
return true;
}
if(a.fenshu == b.fenshu)
{
if(a.xuehao < b.xuehao)
{
return true;
}
else
{
return false;
}
}
return false;
}
int main()
{
int n,m;
cin >> n >> m;
vector<ss>a(n);
for(int i =0;i < n;i++)
{
cin >> a[i].xuehao >> a[i].fenshu;
}
sort(a.begin(),a.end(),pai);
int xian=m*1.5;
int xianfs=a[xian-1].fenshu;
int renshu=xian;
for(int i = xian;i < n;i++)
{
if(a[i].fenshu==xianfs)
{
renshu++;
}
else if(a[i].fenshu<xianfs)
{
break;
}
}
cout << xianfs << " " <<renshu<<endl;
for(int i = 0;i < renshu;i++)
{
if(a[i].xuehao==0)
{
break;
}
cout << a[i].xuehao << " " << a[i].fenshu << endl;
}
return 0;
}
2 条评论
-
rc244wangjiayou1 LV 10 @ 2024-10-20 17:08:20
#include<bits/stdc++.h> using namespace std; int n,m,d,k,s; struct p{ int h,c; }a[5005]; bool cmp(p a,p b){ if(a.c!=b.c)return a.c>b.c; return a.h<b.h; } int main(){ cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i].h>>a[i].c; sort(a+1,a+n+1,cmp); d=floor(m*1.5); k=a[d].c; for(int i=1;i<=n;i++)if(a[i].c>=k)s++; cout<<k<<' '<<s<<endl; for(int i=1;i<=s;i++)cout<<a[i].h<<' '<<a[i].c<<endl; return 0; }
这样
-
2024-10-16 18:55:36@
- 1
信息
- ID
- 1345
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 51
- 已通过
- 10
- 上传者