QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#56809 | #2375. Life Transfer | znk2373065134 | Compile Error | / | / | C++ | 1.4kb | 2022-10-21 16:45:52 | 2022-10-21 16:48:08 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-10-21 16:48:08]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-10-21 16:45:52]
- 提交
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;
flag = true;
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;
}
详细
answer.code: In function ‘int main()’: answer.code:31:5: error: ‘flag’ was not declared in this scope 31 | flag = true; | ^~~~