QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#56810 | #2375. Life Transfer | znk2373065134 | WA | 3ms | 3704kb | C++ | 1.4kb | 2022-10-21 16:48:43 | 2022-10-21 16:48:45 |
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;
ll n, k, lc, lm, pc, pm, pa, d, a[MAXN];
ll ans = 0x7fffffffffffffff, surplus, need, cnt;
bool book[MAXN];
void update(ll i, ll lim, int sgn) {
if (a[i] > lim) surplus += sgn * min(a[i] - lim, d);
else need += sgn * (lim - a[i]);
if (sgn == 1 && lim - a[i] > d) {
book[i] = true;
cnt++;
}
if (sgn == -1 && lim - a[i] > d) {
book[i] = false;
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];
}
std::sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i) {
update(i, lm, 1);
}
if (surplus >= need && !cnt) ans = min(ans, n * pm + need * pa);
for (int i = 1, l = 1, r = n; i <= (n - 1) / k + 1; ++i, --r) {
update(r, lm, -1);
update(r, lc, 1);
while (l < r && l <= i * (k - 1)) {
update(l, lm, -1);
update(l, 1, 1);
++l;
}
if (surplus >= need && !cnt) ans = min(ans, i * pc + max(0LL, n - i * k) * pm + need * pa);
}
if (ans == 0x7ffffffffffffff) ans = -1;
cout << ans;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3704kb
input:
2 2 18 1000 16 1 5 3 16 15
output:
1010
result:
ok single line: '1010'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3476kb
input:
2 2 23 10 15 5 2 2 9 20
output:
9223372036854775807
result:
wrong answer 1st lines differ - expected: '-1', found: '9223372036854775807'