您当前的位置: 首页 > 

MangataTS

暂无认证

  • 2浏览

    0关注

    423博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

L2-017 人以群分(贪心)

MangataTS 发布时间:2022-04-05 00:19:19 ,浏览量:2

题目连接

https://pintia.cn/problem-sets/994805046380707840/problems/994805061056577536

思路

贪心地去想,我们如果将这些人先按照从小到大排序,再分成两部分的话,那么一定是极端地两部分,又由于两堆人数要经可能接近,于是当 n n n 为偶数的时候那么直接拆分成相同的人数的两堆即,否则我们应该让outgoing那一堆的人数多一点,便于我们提高差距

代码
#include
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n"
#define PII pair
#define INF 0x3f3f3f3f

int n;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	vector V(n);
	for(int i = 0;i >V[i];
	sort(V.begin(),V.end());
	int l = n/2,r = n - l;
	cout            
关注
打赏
1665836431
查看更多评论
0.0409s