- 问答
龙虎斗,但不对
- 2023-12-21 18:58:57 @
#include<bits/stdc++.h>
using namespace std;
int c[100010];
int dragon,tiger;
int main()
{
int n;//兵营数
cin >> n;
for(int i = 1;i <= n;i++)
cin >> c[i];
int m,p1,s1,s2,q;//特殊,神兵营1,神兵数1,神兵数2,记录神兵数
cin >> m >> p1 >> s1 >> s2;
for(int i = 1;i < m;i++)
{
dragon += c[i] * ( m - i);
}//计算龙方实力
for(int i = n;i > m;i--)
{
tiger += c[i] * (i - m);
}//虎方实力
if(p1 > m)
tiger += s1 * (p1 - m);
else if(p1 < m)
dragon += s1 * (m - p1);
//神兵1
int jueduizhi = abs(tiger - dragon);//实力差
if(dragon > tiger)
{
int k = jueduizhi;//记录原实力差
int minn = 0;//最小实力差
for(int i = n;i > m;i--)
{
int p = tiger;
tiger += s2 * (i - m);
jueduizhi = abs(tiger - dragon);
if(jueduizhi < minn)
{
minn = jueduizhi;
q = i;
}
tiger = p;
jueduizhi = k;
}
}
else
{
int k = jueduizhi;
int minn = 0;
for(int i = 1;i < m;i++)
{
int p = dragon;
dragon += s2 * (m - i);
jueduizhi = abs(tiger - dragon);
if(jueduizhi < minn)
{
minn = jueduizhi;
q = i;
}
dragon = p;
jueduizhi = k;
}
}
// cout << dragon << ' ' << tiger << endl;
cout << q;
return 0;
}
3 comments
-
经开一中2026届11班关泽瑞 LV 6 @ 2023-12-21 20:59:19
没事,你倒推还原一下。😉q
-
2023-12-21 20:58:51@
so
-
2023-12-21 18:59:33@
我也不知道错哪里了但输出一直是1
- 1