QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#56813 | #2375. Life Transfer | znk2373065134 | WA | 2ms | 3612kb | C++ | 1.2kb | 2022-10-21 16:55:14 | 2022-10-21 16:55:16 |
Judging History
answer
#include <iostream>
#include <algorithm>
typedef long long ll;
using std::cin;
using std::cout;
using std::max;
using std::min;
const int MAXN = 1e5 + 10, INF = 0x7fffffffffffffff;
ll n, k, lc, lm, pc, pm, pa, d, a[MAXN];
ll ans = INF, surplus, need, cnt;
void update(ll val, ll lim, int sgn) {
if (val > lim) surplus += sgn * min(val - lim, d);
else need += sgn * (lim - val);
if (lim - val > d) {
if (sgn == 1) cnt++;
else cnt--;
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k >> lc >> pc >> lm >> pm >> pa >> d;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
update(a[i], lm, 1);
}
if (surplus >= need && !cnt) ans = min(ans, n * pm + need * pa);
std::sort(a + 1, a + n + 1);
for (int i = 1, l = 1, r = n; i <= (n - 1) / k + 1; ++i, --r) {
update(a[r], lm, -1);
update(a[r], lc, 1);
while (l < r && l <= i * (k - 1)) {
update(a[l], lm, -1);
update(a[l], 1, 1);
++l;
}
if (surplus >= need && !cnt) ans = min(ans, i * pc + max(0LL, n - i * k) * pm + need * pa);
}
if (ans == INF) ans = -1;
cout << ans;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3612kb
input:
2 2 18 1000 16 1 5 3 16 15
output:
-1
result:
wrong answer 1st lines differ - expected: '1010', found: '-1'