You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
949 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 100010;
int n;
int m, p1, p2, s1, s2;
int c[N];
signed main() {
cin >> n; // 代表兵营的数量
for (int i = 1; i <= n; i++) cin >> c[i]; // 起始时的工兵数量ci
cin >> m >> p1 >> s1 >> s2;
// 以m号兵营作为分界
// s1位工兵突然出现在了p1号兵营
// 需要选择一个兵营p2并将你手里的s2位工兵全部派往兵营p2
c[p1] += s1;
int s = 0;
for (int i = 1; i <= n; i++) s += c[i] * (m - i); // 双方气势差距
int res = 1e18;
for (int i = 1; i <= n; i++) { // 遍历每个兵营,看看放哪个兵营差距最小
int t = (m - i) * s2 + s;
if (abs(t) < res) {
res = abs(t);
p2 = i;
}
}
printf("%lld\n", p2);
return 0;
}