- 问答
各位看下为什么会错啊 (不是超时的问题)
- 2023-11-25 15:41:07 @
#include<bits/stdc++.h>
using namespace std;
long long n;
long long a[100001];
long long m,p1,s1,s2;
long long x = -0x3f3f3f3f;
long long b[100001],c[100001];
long long s = 0;
int main()
{
cin >> n;
for(int i = 1;i <= n;i ++)
cin >> a[i];
cin >> m >> p1 >> s1 >> s2;
a[p1] = a[p1] + s1;
int q1 = 0,q2 = 0;
for(int i = 1;i < m;i ++)
q1 += a[i] * abs(m-i);
for(int i = m;i <= n;i ++)
q2 += a[i] * abs(m-i);
if(q1 < q2)
{
for(int i = 1;i < m;i ++)
b[i] = q1 + s2*abs(m-i);
for(int j = 1;j <= n;j ++)
{
if(b[j] > x)
{
x = b[j];
s = j;
}
}
}
else if(q1 > q2)
{
for(int i = m + 1;i <= n;i ++)
c[i] = q2 + s2*abs(m-i);
for(int j = 1;j <= n;j ++)
{
if(c[j] > x)
{
x = c[j];
s = j;
}
}
}
cout << s;
return 0;
}
0 comments
No comments so far...