QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#542381#4563. Radio TowersWansur0 48ms13244kbC++231.4kb2024-09-01 00:58:372024-09-01 00:58:37

Judging History

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

  • [2024-09-01 00:58:37]
  • 评测
  • 测评结果:0
  • 用时:48ms
  • 内存:13244kb
  • [2024-09-01 00:58:37]
  • 提交

answer

#include "towers.h"
#include <bits/stdc++.h>
#define ent '\n'

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 12;

int dp[maxn], a[maxn];
int p[20][maxn], lg[maxn];
vector<int> ord;
int n, d;

int get(int l, int r){
    if(l > r) return 0;
    int k = lg[r - l + 1];
    return max(p[k][l], p[k][r - (1 << k) + 1]);
}

void init(int N, std::vector<int> H) {
    n = N;
    for(int i=1;i<=n;i++){
        dp[i] = 2e9;
        a[i] = p[0][i] = H[i - 1];
        if(i > 1) lg[i] = lg[i / 2] + 1;
    }
    for(int k=1;k<20;k++){
        for(int i=1;i + (1 << k) - 1 <= n;i++){
            p[k][i] = max(p[k-1][i], p[k-1][i + (1 << (k - 1))]);
        }
    }
    stack<int> s;
    for(int i=1;i<=n;i++){
        while(s.size() && a[s.top()] > a[i]){
            s.pop();
        }
        if(s.size()){
            dp[i] = get(s.top() + 1, i - 1);
        }
        s.push(i);
    }
    while(s.size()) s.pop();
    for(int i=n;i;i--){
        while(s.size() && a[s.top()] > a[i]){
            s.pop();
        }
        if(s.size()){
            dp[i] = min(dp[i], get(i + 1, s.top() - 1));
        }
        s.push(i);
        if(dp[i] != 2e9){
            ord.push_back(dp[i] - a[i]);
        }
    }
    sort(ord.begin(), ord.end());
}

int max_towers(int l, int r, int D) {
    return upper_bound(ord.begin(), ord.end(), D) - ord.begin() - 1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 22ms
memory: 12956kb

input:

59640
49885 57346 58504 87383 113182 129676 204090 205404 259925 276583 300332 324014 333675 359377 364049 408489 414852 428310 438038 440113 458193 554789 643468 666525 683112 690791 707313 720088 741028 748785 789826 796576 800966 832867 851750 861044 862283 900756 926925 939560 955678 965636 9740...

output:

59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
59637
...

result:

wrong answer 3rd lines differ - expected: '1', found: '59637'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 5856kb

input:

425
753881706 405729786 890889563 29736246 598281970 208352067 357783003 663497023 178397034 4832890 562140755 510307001 354540290 538848551 436879256 86659033 42928516 24145404 749159097 118423198 506851985 204895765 719719998 726244368 991372008 681703480 799303017 657138050 88278945 417801236 260...

output:

293

result:

wrong answer 3rd lines differ - expected: '13', found: '293'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #65:

score: 0
Wrong Answer
time: 48ms
memory: 13244kb

input:

99308
491693640 24020487 317364185 726230755 737284540 951143270 709116045 641023337 360629062 964879440 47884022 532494780 803629825 635450854 688041998 573937055 113198481 191311841 929603572 636688 598629732 895342035 396521271 619919754 716589045 657789547 373121546 866402108 609316614 60046511 ...

output:

66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
66297
...

result:

wrong answer 3rd lines differ - expected: '11903', found: '66297'

Subtask #5:

score: 0
Wrong Answer

Test #86:

score: 0
Wrong Answer
time: 10ms
memory: 12792kb

input:

23881
605288257 422163932 155875880 339929874 76049859 196344969 958160745 767945284 469191956 997116006 387749577 15911341 920437918 367576975 800789357 351557615 283723284 369507452 841548133 643412903 309731505 256549694 370065644 699518122 559017597 347646657 469353381 575240521 501893001 454519...

output:

16683
16817
23730
18850
18653
16547
22102
17205
21868
17959
19002
16403
19282
21111
18520
17415
16220
16646
16086
21120
17559
16824
16578
19131
23416
21851
18230
21907
17653
18980
18914
18890
20738
23095
18062
20875
16175
16913
21940
18000
16679
19128
22602
17326
20929
22986
17279
16861
16644
17804
...

result:

wrong answer 3rd lines differ - expected: '7197', found: '16683'

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%