只对了前两个点,不知道为什么
查看原帖
只对了前两个点,不知道为什么
768667
haotian07楼主2023/11/17 00:51
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;
int h[100005];
struct song
{
	int id;
	int tot;
}s[100005];
bool cmp(song a,song b)
{
	return a.tot>b.tot;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>a>>b;
	int max_id,max_s=-1;
	for(int i=1;i<=a;i++)
	{
		s[i].id=i;
		if(i==b)
		{
			for(int j=1;j<=n;j++)
			{
				int x;
				cin>>x;
				if(x>max_s)
				{
					max_s=x;
					max_id=j;
				}
				s[j].tot+=x;
			}
		}
		else
		{
			for(int j=1;j<=n;j++)
			{
				int x;
				cin>>x;
				s[j].tot+=x;
			}
		}	
	}
	sort(s+1,s+a+1,cmp);
	int flag=0;
	for(int i=1;i<=m;i++)
	{
		if(max_id==s[i].id)
		{
			flag=1;
			break;
		}
	}
	if(flag==0)
	{
		for(int i=1;i<m;i++)
		{
			cout<<s[i].id<<" ";
		}
		cout<<max_id;
		return 0;
	}
	else
	{
		cout<<max_id<<" ";
		for(int i=1;i<=m;i++)
		{
			if(s[i].id!=max_id)
			{
				cout<<s[i].id<<" ";
			}
		}
		return 0;
	}
	return 0;
}
2023/11/17 00:51
加载中...