QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#883729#10050. Bitaro the Brave 2thangthang22 385ms31920kbC++171.7kb2025-02-05 18:30:122025-02-05 18:30:14

Judging History

This is the latest submission verdict.

  • [2025-02-05 18:30:14]
  • Judged
  • Verdict: 22
  • Time: 385ms
  • Memory: 31920kb
  • [2025-02-05 18:30:12]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9;

int n, a[N], b[N];
int Max[N << 2], lazy[N << 2];

void build(int s = 1, int l = 1, int r = n + n - 1){
    if (l == r){
        Max[s] = a[l];
        return;
    }

    int mid = l + r >> 1;

    build(s << 1, l, mid);
    build(s << 1 | 1, mid + 1, r);

    Max[s] = max(Max[s << 1], Max[s << 1 | 1]);
}

void update(int u, int v, int val, int s = 1, int l = 1, int r = n + n - 1){
    if (u <= l && r <= v){
        Max[s] = max(0, Max[s] - val);
        lazy[s] = min(inf, lazy[s] + val);
        return;
    }

    int mid = l + r >> 1;
    if (mid >= u) update(u, v, val, s << 1, l, mid);
    if (mid < v) update(u, v, val, s << 1 | 1, mid + 1, r);

    Max[s] = max(0, max(Max[s << 1], Max[s << 1 | 1]) - lazy[s]);
}

int get(int u, int v, int s = 1, int l = 1, int r = n + n - 1){
    if (u <= l && r <= v) return Max[s];
    if (l > v || r < u) return 0;

    int mid = l + r >> 1;
    int A = get(u, v, s << 1, l, mid);
    int B = get(u, v, s << 1 | 1, mid + 1, r);

    return max(0, max(A, B) - lazy[s]);
}

void process(){
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> a[i], a[i + n] = i;

    for (int i = 1; i <= n; ++ i)
        cin >> b[i], b[i + n] = i;

    build();

    int ans = inf;

    for (int i = n + n - 2; i >= 1; -- i){
        int r = min(n + n - 1, i + n - 1);
        update(i + 1, r, b[i]);
        if (i <= n) ans = min(ans, get(i, i + n - 1));
    }

    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    process();
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

2000
10 9 9 9 9 9 10 9 10 10 9 10 9 10 9 9 10 9 9 9 10 9 10 10 9 10 10 9 9 10 9 10 10 10 9 10 10 9 10 9 9 10 10 9 9 9 9 9 9 9 9 10 9 10 10 10 9 10 9 9 10 9 10 10 10 10 10 9 10 10 10 9 9 9 9 10 9 10 9 10 9 10 10 10 10 9 9 10 10 9 9 9 9 10 9 10 10 10 9 9 9 10 9 9 9 9 10 10 10 9 10 10 10 10 9 10 9 10 9...

output:

9

result:

ok single line: '9'

Test #2:

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

input:

2000
9 9 10 9 10 9 10 9 9 9 10 10 9 10 10 9 9 10 9 10 10 9 10 9 9 9 10 10 10 10 9 10 9 10 9 9 10 9 9 9 9 9 10 10 9 9 9 10 9 9 10 9 9 9 9 10 10 9 10 10 10 10 10 9 9 10 10 9 9 9 9 10 10 10 9 10 9 9 10 9 9 10 9 9 9 10 9 10 10 9 9 10 10 9 9 9 10 9 10 9 10 9 9 10 9 9 9 10 9 10 9 9 9 9 10 9 9 10 10 9 10 1...

output:

9

result:

ok single line: '9'

Test #3:

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

input:

2000
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 0 0...

output:

0

result:

ok single line: '0'

Test #4:

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

input:

2000
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 0 0...

output:

0

result:

ok single line: '0'

Test #5:

score: 10
Accepted
time: 2ms
memory: 9832kb

input:

2000
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 0 0...

output:

0

result:

ok single line: '0'

Test #6:

score: 10
Accepted
time: 2ms
memory: 9832kb

input:

2000
8 6 6 8 8 9 7 6 8 7 10 8 6 8 9 8 10 9 10 10 6 6 10 9 7 8 9 9 7 9 6 10 6 8 6 9 8 10 10 8 9 6 10 10 7 9 10 7 7 10 9 10 10 9 9 10 7 9 8 7 7 9 6 6 9 9 9 6 7 8 8 8 10 8 7 9 10 7 9 6 8 6 6 6 10 10 8 8 9 8 7 9 8 8 10 9 7 6 7 7 7 6 8 10 6 8 9 9 10 9 10 10 7 10 9 7 9 9 6 9 10 6 7 7 10 9 8 7 9 8 8 6 9 10...

output:

10

result:

ok single line: '10'

Test #7:

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

input:

2000
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 0 0...

output:

8

result:

ok single line: '8'

Test #8:

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

input:

2000
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 0 0...

output:

10

result:

ok single line: '10'

Test #9:

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

input:

2000
21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 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:

0

result:

wrong answer 1st lines differ - expected: '8', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #11:

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

input:

2000
100000000 100000001 100000002 100000003 100000004 100000005 100000006 100000007 100000008 100000009 100000010 100000011 100000012 100000013 100000014 100000015 100000016 100000017 100000018 100000019 100000020 100000021 100000022 100000023 100000024 100000025 100000026 100000027 100000028 10000...

output:

99999001

result:

wrong answer 1st lines differ - expected: '99999489', found: '99999001'

Subtask #3:

score: 0
Wrong Answer

Test #27:

score: 19
Accepted
time: 372ms
memory: 30860kb

input:

500000
3 4 10 8 4 3 8 10 1 7 2 5 5 4 8 6 5 9 1 6 5 7 2 9 7 1 6 7 9 6 5 3 2 5 9 8 5 9 7 6 3 8 6 4 7 4 2 1 3 7 9 5 2 10 4 6 3 5 7 7 2 1 3 1 6 7 5 6 8 7 10 6 10 8 5 9 3 4 5 7 9 2 4 2 10 2 5 1 8 1 5 1 5 6 10 7 6 4 6 3 5 9 7 1 7 10 8 8 7 2 3 4 10 3 8 4 1 6 6 1 1 7 5 9 8 1 6 2 2 5 1 1 3 3 1 3 4 1 9 1 5 6 ...

output:

1

result:

ok single line: '1'

Test #28:

score: 19
Accepted
time: 373ms
memory: 30780kb

input:

500000
10 8 9 8 8 10 8 10 9 8 10 10 10 8 8 10 9 9 10 10 9 10 9 9 9 8 8 10 8 9 8 8 9 8 10 8 10 9 10 10 9 8 9 9 9 8 10 10 8 8 10 8 9 8 8 10 10 9 10 9 9 9 9 10 10 9 10 8 8 10 9 8 10 10 8 10 9 9 9 8 10 9 10 9 10 10 8 9 9 10 8 8 9 9 8 8 9 8 8 8 10 9 9 9 10 10 9 10 8 8 9 10 8 10 10 9 8 10 10 9 8 9 10 10 8...

output:

8

result:

ok single line: '8'

Test #29:

score: 19
Accepted
time: 374ms
memory: 30832kb

input:

500000
9 10 6 4 1 1 1 9 1 4 2 9 0 1 7 7 2 10 1 3 0 3 7 1 1 2 9 6 9 8 3 5 4 1 0 1 9 0 8 7 2 0 10 3 7 1 7 10 7 9 9 0 9 5 7 5 6 8 2 10 8 5 4 5 1 6 9 0 9 5 4 5 0 5 2 3 4 6 1 9 7 6 9 3 4 6 1 1 6 9 10 10 9 5 7 10 1 4 2 0 3 3 8 0 8 5 7 10 3 0 0 1 8 2 7 5 2 7 9 8 1 10 0 8 3 1 4 3 3 8 4 10 8 8 4 6 1 6 6 6 10...

output:

0

result:

ok single line: '0'

Test #30:

score: 19
Accepted
time: 377ms
memory: 30320kb

input:

500000
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 0...

output:

8

result:

ok single line: '8'

Test #31:

score: 19
Accepted
time: 376ms
memory: 29744kb

input:

500000
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 0...

output:

10

result:

ok single line: '10'

Test #32:

score: 0
Wrong Answer
time: 368ms
memory: 30284kb

input:

500000
21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21...

output:

0

result:

wrong answer 1st lines differ - expected: '8', found: '0'

Subtask #4:

score: 22
Accepted

Test #42:

score: 22
Accepted
time: 372ms
memory: 30416kb

input:

500000
500000 500064 500128 500192 500256 500320 500384 500448 500512 500576 500640 500704 500768 500832 500896 500960 501024 501088 501152 501216 501280 501344 501408 501472 501536 501600 501664 501728 501792 501856 501920 501984 502048 502112 502176 502240 502304 502368 502432 502496 502560 502624...

output:

499499

result:

ok single line: '499499'

Test #43:

score: 22
Accepted
time: 372ms
memory: 30072kb

input:

500000
500000 500061 500122 500183 500244 500305 500366 500427 500488 500549 500610 500671 500732 500793 500854 500915 500976 501037 501098 501159 501220 501281 501342 501403 501464 501525 501586 501647 501708 501769 501830 501891 501952 502013 502074 502135 502196 502257 502318 502379 502440 502501...

output:

531001

result:

ok single line: '531001'

Test #44:

score: 22
Accepted
time: 371ms
memory: 31416kb

input:

500000
500000 500082 500164 500246 500328 500410 500492 500574 500656 500738 500820 500902 500984 501066 501148 501230 501312 501394 501476 501558 501640 501722 501804 501886 501968 502050 502132 502214 502296 502378 502460 502542 502624 502706 502788 502870 502952 503034 503116 503198 503280 503362...

output:

499949

result:

ok single line: '499949'

Test #45:

score: 22
Accepted
time: 372ms
memory: 31920kb

input:

500000
500000 500005 500010 500015 500020 500025 500030 500035 500040 500045 500050 500055 500060 500065 500070 500075 500080 500085 500090 500095 500100 500105 500110 500115 500120 500125 500130 500135 500140 500145 500150 500155 500160 500165 500170 500175 500180 500185 500190 500195 500200 500205...

output:

502451

result:

ok single line: '502451'

Test #46:

score: 22
Accepted
time: 375ms
memory: 31552kb

input:

500000
500000 500014 500028 500042 500056 500070 500084 500098 500112 500126 500140 500154 500168 500182 500196 500210 500224 500238 500252 500266 500280 500294 500308 500322 500336 500350 500364 500378 500392 500406 500420 500434 500448 500462 500476 500490 500504 500518 500532 500546 500560 500574...

output:

502601

result:

ok single line: '502601'

Test #47:

score: 22
Accepted
time: 375ms
memory: 30224kb

input:

500000
500000 500030 500060 499910 500000 500081 500162 499757 500000 500006 500012 499982 500000 500030 500060 499910 500000 500094 500188 499718 500000 500021 500042 499937 500000 500060 500120 499820 500000 500056 500112 499832 500000 500080 500160 499760 500000 500057 500114 499829 500000 500091...

output:

499997

result:

ok single line: '499997'

Test #48:

score: 22
Accepted
time: 376ms
memory: 31920kb

input:

500000
500000 500091 500182 499727 499636 500000 500015 500030 499955 499940 500000 500058 500116 499826 499768 500000 500097 500194 499709 499612 500000 500003 500006 499991 499988 500000 500035 500070 499895 499860 500000 500002 500004 499994 499992 500000 500012 500024 499964 499952 500000 500089...

output:

500068

result:

ok single line: '500068'

Test #49:

score: 22
Accepted
time: 377ms
memory: 30692kb

input:

500000
500000 500017 500034 499949 499932 500000 500059 500118 499823 499764 500000 500097 500194 499709 499612 500000 500006 500012 499982 499976 500000 500063 500126 499811 499748 500000 500020 500040 499940 499920 500000 500092 500184 499724 499632 500000 500033 500066 499901 499868 500000 500015...

output:

500078

result:

ok single line: '500078'

Test #50:

score: 22
Accepted
time: 372ms
memory: 31840kb

input:

500000
500000 500073 500146 499781 499708 500000 500037 500074 499889 499852 500000 500050 500100 499850 499800 500000 500079 500158 499763 499684 500000 500056 500112 499832 499776 500000 500062 500124 499814 499752 500000 500006 500012 499982 499976 500000 500047 500094 499859 499812 500000 500067...

output:

500082

result:

ok single line: '500082'

Test #51:

score: 22
Accepted
time: 374ms
memory: 30588kb

input:

500000
500000 500055 500110 499835 499780 500000 500064 500128 499808 499744 500000 500100 500200 499700 499600 500000 500049 500098 499853 499804 500000 500058 500116 499826 499768 500000 500093 500186 499721 499628 500000 500060 500120 499820 499760 500000 500025 500050 499925 499900 500000 500055...

output:

499996

result:

ok single line: '499996'

Test #52:

score: 22
Accepted
time: 375ms
memory: 31660kb

input:

500000
500000 500093 500186 500279 500372 500465 499442 499349 499256 499163 500000 500054 500108 500162 500216 500270 499676 499622 499568 499514 500000 500008 500016 500024 500032 500040 499952 499944 499936 499928 500000 500020 500040 500060 500080 500100 499880 499860 499840 499820 500000 500070...

output:

500191

result:

ok single line: '500191'

Test #53:

score: 22
Accepted
time: 378ms
memory: 31680kb

input:

500000
500000 500056 500112 500168 500224 500280 499664 499608 499552 499496 500000 500099 500198 500297 500396 500495 499406 499307 499208 499109 500000 500001 500002 500003 500004 500005 499994 499993 499992 499991 500000 500073 500146 500219 500292 500365 499562 499489 499416 499343 500000 500062...

output:

500221

result:

ok single line: '500221'

Test #54:

score: 22
Accepted
time: 372ms
memory: 30192kb

input:

500000
500000 500048 500096 500144 500192 500240 499712 499664 499616 499568 500000 500070 500140 500210 500280 500350 499580 499510 499440 499370 500000 500065 500130 500195 500260 500325 499610 499545 499480 499415 500000 500045 500090 500135 500180 500225 499730 499685 499640 499595 500000 500065...

output:

499994

result:

ok single line: '499994'

Test #55:

score: 22
Accepted
time: 375ms
memory: 31760kb

input:

500000
500000 500062 500124 500186 500248 500310 499628 499566 499504 499442 500000 500086 500172 500258 500344 500430 499484 499398 499312 499226 500000 500006 500012 500018 500024 500030 499964 499958 499952 499946 500000 500041 500082 500123 500164 500205 499754 499713 499672 499631 500000 500081...

output:

499994

result:

ok single line: '499994'

Subtask #5:

score: 0
Wrong Answer

Test #56:

score: 28
Accepted
time: 375ms
memory: 31228kb

input:

500000
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 0...

output:

1000000000

result:

ok single line: '1000000000'

Test #57:

score: 28
Accepted
time: 383ms
memory: 31356kb

input:

500000
878732262 659850111 642167668 527055743 874918922 910516925 632227950 347446862 789657007 199359454 271738438 413064348 380649122 749297150 271061420 547940090 988295141 857908755 423119545 951447379 653726190 751491775 36946795 133415601 340869239 473110303 389127597 765480107 169286051 1172...

output:

2573

result:

ok single line: '2573'

Test #58:

score: 28
Accepted
time: 385ms
memory: 31380kb

input:

500000
92053807 821003041 998709647 997639666 737664671 52294529 92882552 897389465 838476243 66499365 841862027 570820639 265984300 881163733 222035000 645755487 108495075 557930072 951874990 248796463 803052472 211179064 180368193 37679412 58792565 482515541 85145894 348741658 333665969 957099801 ...

output:

2908

result:

ok single line: '2908'

Test #59:

score: 28
Accepted
time: 375ms
memory: 30316kb

input:

500000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1...

output:

100

result:

ok single line: '100'

Test #60:

score: 0
Wrong Answer
time: 384ms
memory: 31336kb

input:

500000
100000000 100000001 100000002 100000003 100000004 100000005 100000006 100000007 100000008 100000009 100000010 100000011 100000012 100000013 100000014 100000015 100000016 100000017 100000018 100000019 100000020 100000021 100000022 100000023 100000024 100000025 100000026 100000027 100000028 100...

output:

99750001

result:

wrong answer 1st lines differ - expected: '99875428', found: '99750001'