- 问答
龙虎斗为啥只有32分
- 2023-11-25 15:43:17 @
#include<bits/stdc++.h>
using namespace std;
int a[999999],qishi[999999];
int main()
{
long long n,m,p1,s1,s2;
long long dragon=0,tiger=0;
cin >> n;
for(int i=1;i<=n;i++)
cin >> a[i];
cin >> m >> p1 >> s1 >> s2;
a[p1]+=s1;
for(int i=1;i<=n;i++)
qishi[i]=a[i]*abs(i-m);
for(int i=1;i<m;i++)
dragon+=qishi[i];
for(int i=n;i>m;i--)
tiger+=qishi[i];
long long c=abs(dragon-tiger),maxn=m;
if(dragon>tiger)
{
for(int i=m+1;i<=n;i++)
{
if(c>abs(tiger+(i*s2)-dragon))
{
c=abs(tiger+(i*s2)-dragon);
maxn=i;
}
}
cout << maxn << endl;
}
if(dragon<tiger)
{
for(int i=1;i<m;i++)
{
if(c>abs(dragon+(i*s2)-tiger))
{
c=abs(dragon+(i*s2)-tiger);
maxn=i;
}
}
cout << maxn << endl;
}
return 0;
}
2 comments
-
zhangyurui SVIP LV 9 @ 2023-11-25 22:31:33
求解😭
-
2023-11-25 16:06:04@
等我把函数题解发完
- 1