Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

35 lines
949 B
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}