提交时间:2024-01-13 15:20:34
运行 ID: 36459
#include<iostream> #include<algorithm> using namespace std; struct node{ int id; int s; }xs[1000]; bool cmp(node a, node b){ if(a.s==b.s) return a.id<b.id; else return a.s>b.s; } int main() { int n,m,sum=0; cin>>n>>m; m=m*1.5+1; for(int i=1;i<=n;i++){ cin>>xs[i].id>>xs[i].s; sum+=xs[i].s; } sort(xs+1,xs+1+n,cmp); cout<<sum/n<<" "<<m; for(int i=1;i<=m;i++){ cout<<xs[i].id<<" "<<xs[i].s; } return 0; }