QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#127512#2785. Boxes with souvenirsQwerty1232#10 1ms3856kbC++201.7kb2023-07-19 19:11:542024-07-04 00:46:46

Judging History

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

  • [2024-07-04 00:46:46]
  • 评测
  • 测评结果:10
  • 用时:1ms
  • 内存:3856kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-19 19:11:54]
  • 提交

answer

#include "boxes.h"

#include <bits/stdc++.h>

long long delivery(int n, int k, int L, int p[]) {
    while (n && *p == 0) {
        n--;
        p++;
    }
    if (n == 0) {
        return 0;
    }

    int it = std::lower_bound(p, p + n, (L + 1) / 2) - p;
    assert(std::is_sorted(p, p + n));

    int left = it / k * k;
    int right = n - (n - it) / k * k;

    int64_t ans = 0;
    for (int i = 0; i < left; i += k) {
        ans += 2 * p[i + k - 1];
    }
    for (int i = n - 1; i >= right; i -= k) {
        ans += 2 * (L - p[i - k + 1]);
    }
    if (left == it || right == it) {
        if (left == it && right == it) {
            return ans;
        } else if (left == it) {
            ans += 2 * (L - p[it]);
        } else {
            ans += 2 * p[it - 1];
        }
        return ans;
    }
    if (right - left <= k) {
        ans += L;
    } else {
        int64_t min = 2 * L;
        min = std::min<int64_t>(min, 2 * (p[it - 1] + L - p[it]));
        for (int i = left; i < right; i++) {
            if (i - left < k) {
                min = std::min<int64_t>(min, L + 2 * p[i]);
            }
            if (right - i <= k) {
                min = std::min<int64_t>(min, L + 2 * (L - p[i]));
            }
        }
        ans += min;
        // ans += 2 * (L - p[it]);
        // ans += 2 * p[it - 1];
    }

    // int64_t ans1 = 0;
    // for (int i = 0; i < it; i += k) {
    //     int nx = std::min(it - 1, i + k - 1);
    //     ans1 += 2 * p[nx];
    // }
    // for (int i = n - 1; i >= it; i -= k) {
    //     int nx = std::max(it, i - k + 1);
    //     ans1 += 2 * (L - p[nx]);
    // }
    // ans = std::min(ans, ans1);

    return ans;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 3748kb

input:

1 1 1000000000
210758687

output:

421517374

result:

ok single line: '421517374'

Test #2:

score: 10
Accepted
time: 0ms
memory: 3740kb

input:

1000 1 1000000000
1808509 2182084 3015527 4447494 7769779 8792029 9883237 12829051 12902231 13338930 16688684 16992515 17866419 19063417 20124997 20125047 20514891 20917910 24004241 25917774 30411202 34419407 34944244 36371532 36402573 39271076 39612282 40912226 41119528 41176691 42741034 42801382 4...

output:

511681980406

result:

ok single line: '511681980406'

Test #3:

score: 10
Accepted
time: 0ms
memory: 3792kb

input:

1000 1 1000
2 3 4 4 4 7 7 8 10 12 12 13 14 15 16 16 17 17 18 21 22 23 24 24 25 28 30 30 30 30 32 32 34 34 34 34 35 35 35 35 35 36 36 36 37 39 41 42 42 43 43 44 44 44 45 46 46 46 47 48 49 51 52 53 55 56 58 60 61 61 62 63 64 68 69 70 72 74 75 76 76 76 78 78 80 81 83 83 84 84 85 85 86 86 88 88 90 92 92...

output:

511638

result:

ok single line: '511638'

Test #4:

score: 10
Accepted
time: 0ms
memory: 3720kb

input:

1000 1 5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2322

result:

ok single line: '2322'

Test #5:

score: 10
Accepted
time: 1ms
memory: 3732kb

input:

1000 1 1000000000
447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 447532220 44...

output:

895064440000

result:

ok single line: '895064440000'

Test #6:

score: 10
Accepted
time: 0ms
memory: 3752kb

input:

1000 1 1000000000
18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 18457857 61895049 61895049 61895049 61895049 61895049 61895049 61895049 61895049 61895049 61895049 618...

output:

619577021140

result:

ok single line: '619577021140'

Test #7:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

1000 1 1000000000
159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 159227065 15...

output:

294049546692

result:

ok single line: '294049546692'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 10
Accepted
time: 0ms
memory: 3788kb

input:

1000 1000 1000
0 0 1 2 3 3 4 5 5 6 6 7 8 8 8 9 10 11 11 11 12 13 13 13 14 14 15 16 17 17 17 18 20 20 21 21 24 25 25 26 30 31 34 34 35 38 40 43 44 46 46 46 47 47 51 52 52 52 55 56 58 62 64 65 67 68 69 72 73 75 76 77 78 79 79 80 83 84 85 85 86 86 87 88 88 88 92 92 92 95 95 96 98 98 99 99 100 100 101 1...

output:

1000

result:

ok single line: '1000'

Test #9:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

1000 1000 5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

5

result:

ok single line: '5'

Test #10:

score: 10
Accepted
time: 0ms
memory: 3776kb

input:

1000 1000 1000000000
154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846 154376846...

output:

308753692

result:

ok single line: '308753692'

Test #11:

score: 10
Accepted
time: 0ms
memory: 3740kb

input:

1000 1000 1000000000
198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287 198812287...

output:

1000000000

result:

ok single line: '1000000000'

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

input:

1000 1000 1000000000
84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 84700188 ...

output:

1000000000

result:

wrong answer 1st lines differ - expected: '665477708', found: '1000000000'

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 15
Accepted
time: 0ms
memory: 3712kb

input:

10 5 5
0 0 0 0 0 1 3 3 3 4

output:

5

result:

ok single line: '5'

Test #16:

score: 15
Accepted
time: 1ms
memory: 3732kb

input:

10 5 1000000000
334882664 334882664 334882664 334882664 334882664 334882664 334882664 334882664 334882664 334882664

output:

1339530656

result:

ok single line: '1339530656'

Test #17:

score: 15
Accepted
time: 1ms
memory: 3728kb

input:

10 2 1000000000
85975415 85975415 85975415 85975415 85975415 85975415 85975415 85975415 85975415 105352579

output:

898508478

result:

ok single line: '898508478'

Test #18:

score: 15
Accepted
time: 0ms
memory: 3856kb

input:

10 2 1000000000
450369670 450369670 450369670 450369670 450369670 450369670 450369670 450369670 973255696 973255696

output:

3656445968

result:

ok single line: '3656445968'

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 3732kb

input:

10 10 1000000000
20859 165911 251492 256622 477740 805842 835605 999196078 999415731 999776268

output:

1000000000

result:

wrong answer 1st lines differ - expected: '3279054', found: '1000000000'

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%