Submission #771426

# Submission time Handle Problem Language Result Execution time Memory
771426 2023-07-03T01:33:03 Z PurpleCrayon Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 7128 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int N = 1e5+10, MOD = 1e9+7;
const ll INF = 1e18+10;

int n, a[N];

void init(int _n, vector<int> H) {
    n = _n;
    for (int i = 0; i < n; i++) {
        a[i] = H[i];
    }
}

int max_towers(int l, int r, int d) {
    vector<int> a(r - l + 1);
    for (int i = 0; i < sz(a); i++) a[i] = ::a[i + l];
    n = sz(a);

    set<int> use;
    vector<int> p(n); iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int x, int y) { return a[x] > a[y]; });
    vector<int> one(n, -1), two(n, -1);
    for (int x : p) {
        auto it = use.lower_bound(x);
        if (it != use.end() && a[*it] - a[x] < d) continue;
        if (it != use.end()) one[x] = *it;

        if (it != use.begin() && a[*prev(it)] - a[x] < d) continue;
        if (it != use.begin()) two[x] = *prev(it);
        use.insert(x);
    }

    int ans = 0;
    for (int x : use) {
        auto it = use.find(x);
        int c1 = (next(it) == use.end() ? -1 : *next(it));
        int c2 = (it == use.begin() ? -1 : *prev(it));
        if (c1 == one[x] && c2 == two[x]) {
            ans++;
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4098 ms 1852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4048 ms 7128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4083 ms 1936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4098 ms 1852 KB Time limit exceeded
2 Halted 0 ms 0 KB -