QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#219521 | #7144. Candies | ckiseki# | WA | 7ms | 3864kb | C++20 | 1.5kb | 2023-10-19 15:55:27 | 2023-10-19 15:55:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++f)
cerr << (f ? ", " : "") << *L++;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define orange(...) safe
#define debug(...) safe
#endif
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n);
for (int &ai : a)
cin >> ai;
auto solve = [&](int add) {
min_heap<pair<int64_t, int>> pq;
pq.emplace(a[0] + add, 0);
for (int i = 1; i < n; ++i)
pq.emplace(a[i], i);
for (int iter = 0; iter < m; ++iter) {
auto [v, i] = pq.top();
pq.pop();
v += x;
pq.emplace(v, i);
}
while (pq.top().second != 0)
pq.pop();
return pq.top().first;
};
int64_t ans = solve(y);
int L = max(0, y - x), R = y;
while (R - L > 1) {
int M = (L + R) >> 1;
int64_t v = solve(m);
if (v >= ans)
L = M;
else
R = M;
}
cout << max(ans, solve(L)) << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3512kb
input:
2 1 2 2 1 2
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
10 9 4 3 19 32 11 1 3 3 3 12 17 34
output:
22
result:
ok 1 number(s): "22"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
10 8 2 25 31 12 12 34 2 14 1 8 10 34
output:
56
result:
ok 1 number(s): "56"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
10 7 4 23 22 30 23 34 28 33 8 24 22 15
output:
45
result:
ok 1 number(s): "45"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
10 9 5 26 45 11 30 40 29 22 33 14 35 3
output:
71
result:
ok 1 number(s): "71"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
10 4 4 3 7 14 20 13 7 11 10 19 15 7
output:
14
result:
ok 1 number(s): "14"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
10 9 2 11 6 29 41 9 8 3 33 9 8 21
output:
17
result:
ok 1 number(s): "17"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
10 10 4 39 16 33 13 30 1 17 22 31 25 36
output:
55
result:
ok 1 number(s): "55"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
10 9 3 41 25 11 39 38 32 36 39 41 12 16
output:
66
result:
ok 1 number(s): "66"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
10 9 2 34 32 17 29 34 3 31 18 2 34 20
output:
66
result:
ok 1 number(s): "66"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
10 6 4 21 20 5 23 20 17 22 23 27 6 21
output:
41
result:
ok 1 number(s): "41"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3656kb
input:
10 192452 1 349793 261556 751823 78443 365930 686964 56471 824875 420739 392610 121201
output:
611349
result:
ok 1 number(s): "611349"
Test #13:
score: 0
Accepted
time: 7ms
memory: 3864kb
input:
10 190339 3 183831 489416 225873 347356 274719 48019 323021 941337 458359 223575 671498
output:
673247
result:
ok 1 number(s): "673247"
Test #14:
score: 0
Accepted
time: 5ms
memory: 3624kb
input:
10 121541 5 568482 297528 295544 425227 299848 107171 366521 203644 506124 384806 376747
output:
866010
result:
ok 1 number(s): "866010"
Test #15:
score: 0
Accepted
time: 5ms
memory: 3628kb
input:
10 155746 2 127355 708544 7964 662942 750109 293269 546552 348710 683848 528759 27248
output:
835899
result:
ok 1 number(s): "835899"
Test #16:
score: 0
Accepted
time: 7ms
memory: 3864kb
input:
10 189950 4 320620 727257 452462 146035 704003 281528 175747 72858 312138 114935 224412
output:
1047877
result:
ok 1 number(s): "1047877"
Test #17:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
10 114766 1 356824 375173 146633 70072 31817 55471 553493 54270 173424 118747 52364
output:
731997
result:
ok 1 number(s): "731997"
Test #18:
score: -100
Wrong Answer
time: 7ms
memory: 3600kb
input:
10 145873 5 8025 281544 523494 95770 241062 421293 384178 324742 388922 65406 722173
output:
349184
result:
wrong answer 1st numbers differ - expected: '349185', found: '349184'