QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241619#7144. Candies8BQube#RE 15ms5548kbC++201.4kb2023-11-06 14:19:142023-11-06 14:19:15

Judging History

你现在查看的是最新测评结果

  • [2023-11-06 14:19:15]
  • 评测
  • 测评结果:RE
  • 用时:15ms
  • 内存:5548kb
  • [2023-11-06 14:19:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define SZ(a) ((int)a.size())

int arr[200005], ub[200005];
vector<ll> gap;

int lt(ll x) {
    return lower_bound(ALL(gap), x) - gap.begin();
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m, x, y, a1;
    cin >> n >> m >> x >> y >> a1, --n;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i = 0; i < n; ++i)
        pq.push(arr[i]);
    while (SZ(gap) <= m) {
        gap.pb(pq.top());
        ll t = pq.top() + x;
        pq.pop(), pq.push(t);
    }
    ll ans = a1 + y;
    ub[m + 1] = 0;
    for (int i = m; i >= 1; --i) {

        auto check = [&](ll mid) {
            return i + lt(a1 + mid + (ll)(i - 1) * x) > m; 
        };

        if (check(0)) {
            ub[i] = 0;
        }
        else {
            int l = 0, r = y + 1;
            while (r - l > 1) {
                int mid = (l + r) >> 1;
                if (check(mid))
                    r = mid;
                else
                    l = mid;
            }
            ub[i] = r;
            // [ub[i + 1], ub[i])
            if (ub[i + 1] < ub[i])
                ans = max(ans, (ll)i * x + a1 + ub[i] - 1);
        }
    }
    cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

2 1 2 2
1 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

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: 3600kb

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: 3592kb

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: 3776kb

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: 3820kb

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: 3600kb

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: 3780kb

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: 3552kb

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: 3600kb

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: 3ms
memory: 5416kb

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: 6ms
memory: 5412kb

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: 15ms
memory: 4644kb

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: 5192kb

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: 3ms
memory: 5548kb

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: 4ms
memory: 4660kb

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: 0
Accepted
time: 14ms
memory: 5168kb

input:

10 145873 5 8025
281544 523494 95770 241062 421293 384178 324742 388922 65406 722173

output:

349185

result:

ok 1 number(s): "349185"

Test #19:

score: 0
Accepted
time: 6ms
memory: 5156kb

input:

10 176980 1 207389
168885 67047 821956 46492 656129 825751 2363 381763 454484 860355

output:

376274

result:

ok 1 number(s): "376274"

Test #20:

score: 0
Accepted
time: 6ms
memory: 5428kb

input:

10 187943 4 836477
583977 521068 887641 397078 425376 883500 915076 773036 590 867354

output:

1420454

result:

ok 1 number(s): "1420454"

Test #21:

score: 0
Accepted
time: 3ms
memory: 4120kb

input:

10 80376 1 71852
348246 178594 146591 264532 117621 252046 131684 116962 222868 376178

output:

420098

result:

ok 1 number(s): "420098"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

100 98 5 277
124 141 254 316 264 129 191 410 357 16 410 449 161 459 175 117 396 388 368 2 460 278 130 29 391 75 453 292 315 157 187 276 52 457 221 172 317 441 173 164 334 217 12 140 89 138 36 387 227 152 152 134 322 65 377 83 257 490 119 81 418 21 1 98 315 66 451 337 170 177 291 39 127 110 238 54 15...

output:

401

result:

ok 1 number(s): "401"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

100 44 4 195
49 143 124 77 198 28 44 132 187 82 204 210 51 185 204 173 150 2 44 89 17 154 136 23 73 8 202 166 160 178 187 16 35 148 94 213 195 10 132 132 99 212 77 33 16 77 2 161 9 109 161 169 3 162 84 108 26 56 202 164 58 113 128 189 52 206 45 38 174 195 31 9 98 107 144 107 84 214 106 166 151 213 3...

output:

244

result:

ok 1 number(s): "244"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

100 84 5 146
153 384 295 288 387 211 389 129 252 326 96 308 81 120 316 180 6 333 390 346 87 69 359 396 166 395 230 419 227 114 254 246 39 119 346 288 229 221 83 367 260 191 158 275 75 126 95 283 263 41 215 401 145 115 187 321 170 268 106 401 317 260 171 240 116 415 69 250 111 76 185 350 183 74 168 3...

output:

299

result:

ok 1 number(s): "299"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

100 87 3 415
428 44 313 341 262 23 349 241 106 117 169 348 116 285 121 377 290 218 11 9 224 240 385 96 274 21 392 257 381 87 320 323 136 298 393 25 182 112 20 96 111 31 281 99 222 10 66 408 332 390 303 112 27 196 416 238 279 126 431 235 374 102 108 72 168 137 337 65 64 333 348 213 99 386 13 337 402 ...

output:

843

result:

ok 1 number(s): "843"

Test #26:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

100 83 1 341
372 210 3 118 328 118 310 158 152 220 261 366 308 298 411 19 215 265 84 15 16 387 118 159 195 255 60 340 74 81 40 330 285 134 19 57 406 288 61 161 380 225 23 161 396 20 104 405 405 74 177 392 164 109 38 376 49 181 240 219 234 328 375 383 33 87 146 401 140 263 399 238 125 38 297 105 179 ...

output:

713

result:

ok 1 number(s): "713"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

100 92 4 134
115 48 346 425 7 460 64 274 265 407 451 331 2 127 325 40 109 408 299 407 111 248 206 361 387 72 125 127 451 329 432 401 253 363 432 66 275 154 96 415 191 208 370 323 123 413 80 274 22 171 275 83 317 346 51 284 112 193 209 1 247 27 328 25 393 131 404 328 460 180 267 299 310 414 447 104 2...

output:

249

result:

ok 1 number(s): "249"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

100 99 2 321
145 384 339 96 147 399 410 287 361 454 212 207 93 428 224 381 188 186 306 220 178 390 407 490 217 288 119 290 81 140 386 380 126 209 159 173 102 280 277 247 152 367 54 372 348 318 331 287 239 5 254 353 221 218 340 494 332 249 332 271 52 174 355 241 129 262 391 433 331 153 44 159 461 166...

output:

466

result:

ok 1 number(s): "466"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

100 81 4 95
159 135 34 382 321 353 219 129 155 343 181 360 398 338 165 98 208 378 182 40 330 44 135 25 234 252 46 323 211 157 109 397 245 148 311 179 325 322 146 73 116 387 275 144 270 155 115 29 313 398 283 379 88 316 233 352 247 76 70 254 140 241 367 208 338 128 30 323 62 238 115 38 272 73 82 51 3...

output:

254

result:

ok 1 number(s): "254"

Test #30:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

100 70 2 10
5 336 314 226 114 21 68 291 10 60 334 30 112 140 58 44 62 176 213 129 50 296 227 64 210 173 85 247 311 280 190 329 303 54 117 94 314 54 287 307 287 121 249 276 169 276 30 298 310 186 127 21 70 197 276 84 156 118 309 281 3 153 75 290 294 137 324 194 167 325 44 273 117 10 266 260 46 71 322...

output:

36

result:

ok 1 number(s): "36"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

100 83 3 365
168 207 166 173 282 322 172 293 31 302 7 255 357 103 207 386 269 240 129 178 203 310 86 216 99 10 336 344 110 302 79 96 329 131 350 376 48 125 376 325 279 222 8 39 239 306 235 142 135 280 407 32 165 367 157 121 176 297 39 380 27 277 226 204 14 321 40 397 402 20 247 247 206 37 344 258 21...

output:

533

result:

ok 1 number(s): "533"

Test #32:

score: -100
Runtime Error

input:

1 78 775 325531
90984

output:


result: