Submission #628211

# Submission time Handle Problem Language Result Execution time Memory
628211 2022-08-13T08:12:24 Z TheQuantiX Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 3272 KB
// Made by TheQuantiX
#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,sse4.2,bmi,bmi2,lzcnt,popcnt")

using namespace std;

using ll = long long;

constexpr ll MAXN = 1e5;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000000000000000LL;

int tt, n, q, m, k, x, y, a, b, c, d;
vector<int> v;
vector<int> tr;

void build(ll x, ll l, ll r) {
    if (l == r) {
        tr[x] = v[l];
        return;
    }
    ll mid = (l + r) / 2;
    build(2 * x + 1, l, mid);
    build(2 * x + 2, mid + 1, r);
    tr[x] = max(tr[2 * x + 1], tr[2 * x + 2]);
}

ll query(ll x, ll l, ll r, ll lt, ll rt) {
    if (rt < l || r < lt) {
        return -INF;
    }
    if (rt < lt) {
        return -INF;
    }
    if (l <= lt && rt <= r) {
        return tr[x];
    }
    ll mid = (lt + rt) / 2;
    return max(query(2 * x + 1, l, r, lt, mid), query(2 * x + 2, l, r, mid + 1, rt));
}

void init(int n1, vector<int> h) {
    n = n1;
    v = h;
    tr.resize(h.size() * 4);
    build(0, 0, n - 1);
}

int max_towers(int l, int r, int d) {
    vector<ll> dp(n, 1);
    for (int i = l; i <= r; i++) {
        for (int j = i + 2; j <= r; j++) {
            ll mx = query(0, i, j, 0, n - 1);
            if (mx - v[i] >= d && mx - v[j] >= d) {
                dp[j] = max(dp[j], dp[i] + 1);
            }
        }
    }
    if (*max_element(dp.begin(), dp.end()) == 1) {
        return 0;
    }
    return *max_element(dp.begin(), dp.end());
}

//void solve() {
//    cin >> n >> q;
//    vector<int> v(n);
//    for (int i = 0; i < n; i++) {
//        cin >> v[i];
//    }
//    init(n, v);
//    for (int i = 0; i < q; i++) {
//        cin >> a >> b >> c;
//        cout << max_towers(a, b, c) << endl;
//    }
//}
//
//int main() {
//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
//    cout << fixed;
//    cout << setprecision(10);
//    tt = 1;
////    cin >> tt;
//    while (tt --> 0) {
//        solve();
//    }
//}
# Verdict Execution time Memory Grader output
1 Execution timed out 4061 ms 2104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 79 ms 340 KB Output is correct
3 Correct 59 ms 348 KB Output is correct
4 Correct 33 ms 296 KB Output is correct
5 Correct 63 ms 356 KB Output is correct
6 Correct 9 ms 336 KB Output is correct
7 Correct 44 ms 360 KB Output is correct
8 Incorrect 4 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 79 ms 340 KB Output is correct
3 Correct 59 ms 348 KB Output is correct
4 Correct 33 ms 296 KB Output is correct
5 Correct 63 ms 356 KB Output is correct
6 Correct 9 ms 336 KB Output is correct
7 Correct 44 ms 360 KB Output is correct
8 Incorrect 4 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 3272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4067 ms 1104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 79 ms 340 KB Output is correct
3 Correct 59 ms 348 KB Output is correct
4 Correct 33 ms 296 KB Output is correct
5 Correct 63 ms 356 KB Output is correct
6 Correct 9 ms 336 KB Output is correct
7 Correct 44 ms 360 KB Output is correct
8 Incorrect 4 ms 336 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4061 ms 2104 KB Time limit exceeded
2 Halted 0 ms 0 KB -