Submission #836189

# Submission time Handle Problem Language Result Execution time Memory
836189 2023-08-24T08:31:55 Z tengiz05 Radio Towers (IOI22_towers) C++17
0 / 100
496 ms 1848 KB
#include "towers.h"

#include <bits/stdc++.h>
using namespace std;

vector<int> A, B, H;
int k;
int n;
void init(int N, vector<int> h) {
    n = N;
    k = n - 1;
    H = h;
    for (int i = 0; i < n - 1; i++) {
        if (h[i] < h[i + 1]) {
            A.push_back(h[i]);
        } else {
            k = i;
            break;
        }
    }
    for (int i = n - 1; i > 0; i--) {
        if (h[i] < h[i - 1]) {
            B.push_back(h[i]);
        }
    }
}

int max_towers(int L, int R, int D) {
    int l = upper_bound(A.begin(), A.end(), H[k] - D) - A.begin();
    int r = upper_bound(B.begin(), B.end(), H[k] - D) - B.begin();
    r = n - r;
    int a = max(0, l - L);
    int b = max(0, R - r);
    if (a > 0 && b > 0) {
        return a + b;
    } else {
        return 0;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 293 ms 1360 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 496 ms 1848 KB 1st lines differ - on the 1st token, expected: '11903', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 303 ms 592 KB 1st lines differ - on the 1st token, expected: '7197', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 293 ms 1360 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -