为啥48分
查看原帖
为啥48分
112937
yuangq楼主2018/11/14 20:54
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long n,m,p1,s1,s2;
long long sl,sh,mins=9e18,k=0;
struct dian
{
	long long qishi;
	long long shu;
}a[100005];
int main()
{
	//freopen("fight.in","r",stdin);
	//freopen("fight.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].shu;
	}
	cin>>m>>p1>>s1>>s2;
	for(int i=1;i<=n;i++)
	{
		int t=max(i-m,m-i);
		if(i==p1)
		{
			a[i].shu+=s1;
		}
		a[i].qishi=a[i].shu*t;
		if(i<m)
		{
			sl+=a[i].qishi;
		}
		else if(i>m)
		{
			sh+=a[i].qishi;
		}
	}
	for(int p2=1;p2<n;p2++)
	{
		long long n1=sl,n2=sh;
		if(p2<m)
		{
			n1+=s2*(m-p2);
		}
		else if(p2>m)
		{
			n2+=s2*(p2-m);
		}
		long long t=max(n1-n2,n2-n1);
		if(t<mins)
		{
			k=p2;
			mins=t;
		}
	}
	cout<<k;
	return 0;
}
2018/11/14 20:54
加载中...