湖大训练赛第十场 Final Standings

Final Standings
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:262144KB
Total submit users: 27, Accepted users: 23
Problem 12910 : Special judge
Problem description

Formula TheByte is the most famous race competition in ByteLand. The competition is over and each of n drivers has a number of points. A driver that has more points is placed higher.

Final standings are not disclosed yet, but we know that the total number of points earned by all the drivers is p and there are only d different numbers of points among top k drivers.

The ByteLand Times asks you to guess final standings based on the given information.


Input

The only line of the input file contains four integer numbers: n, p, k and d — the number of drivers, the number of points, the number of top drivers, and the number of different numbers of points among top k drivers (1 ≤ k ≤ n ≤ 1000; 0 ≤ p ≤ 1000000; 1 ≤ d ≤ k).


Output

Output the possible standings that match given n, p, k and d.

If it is possible to create the correct final standings, you should output final standings. The i-th line of the final standings must contain a number of points earned by i-th driver. Drivers should be ordered by number of points in the descending order.

If there is no possible final standings satisfying the given data, output the single line “Wrong information”.


Sample Input
3 4 2 2

3 5 2 2

2 5 2 1
Sample Output
2
1
1

3
2
0

Wrong information
 

题意:有N个选手,M个分值,前K个人有P个不同的分值。当然前者分值必然不小于后者。问这N个人是否满足这样的要求。满足则输出任意一组情况。不满足则Wrong。

题解:我们先判断最小的分值(d-1)*d/2=min。注意可以分值为0。然后如果d==1的话。就有两种情况判断,如果k==n,那么p就必须平均分配给k个人。也就是p%k==0,否则W.如果n!=k。并且剩下的分值p-(p/k*K)还大于前者的话也是W.否则就直接分配ans=p/k给前k个。然后再递减分配给剩下的人。绝对会满足条件。

若是d!=1的话。就按0,1,2,3分配给后n-1个人,那么第一个人就是剩下的p。保证p会大于后面的人的分值。因为前面已经进行判断过了。然后后面的lose统一分配0就OK了。有可能会与比我的算法更好的构造方式。欢迎指教。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
#define LL __int64
#define EPS 1e-8
using namespace std;
int a[10010];
int main()
{
	int n,p,k,d,i;
	//freopen("out.txt","w",stdout);
	while (~scanf("%d%d%d%d",&n,&p,&k,&d))
	{
		//int max=(2*k-d+1)*d/2+(k-d)*k;
		int min=(d-1)*d/2;
		if (p<min)
		{
			puts("Wrong information");
			continue;
		}
		int i=0;int ans;
		if (d==1)
		{
			ans=p/k;
			if ((p-ans*k>0 && (n-k)==0) || ((n-k)!=0 && (p-ans*k)/(n-k)>ans))
			{
				puts("Wrong information");continue;
			}
			else
			{
				for (i=1;i<=k;i++)
					cout<<ans<<endl;
				int s=p-ans*k;
				for (i=1;i<=n-k;i++)
				{
					if (s>ans)
					{
						cout<<ans<<endl;
						s-=ans;
					}
					else 
					{
						cout<<s<<endl;
						s-=s;
					}
				}
			}
		}
		else
		{
			for (i=0;i<d-1;i++)
			{
				a[i]=i;
				p-=i;
			}
			if (p>0) cout<<p<<endl;
			for (i=d-2;i>=0;i--)
				cout<<a[i]<<endl;
			for (i=1;i<=n-d;i++)
				cout<<"0"<<endl;
		}
	}
	return 0;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值