답안 #628214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
628214 2022-08-13T08:13:43 Z TheQuantiX 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 3268 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();
//    }
//}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4026 ms 2148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 81 ms 336 KB Output is correct
3 Correct 60 ms 344 KB Output is correct
4 Correct 34 ms 340 KB Output is correct
5 Correct 57 ms 344 KB Output is correct
6 Correct 9 ms 336 KB Output is correct
7 Correct 45 ms 344 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 13 ms 364 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 11 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 46 ms 336 KB Output is correct
14 Correct 31 ms 464 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 136 ms 336 KB Output is correct
17 Correct 19 ms 336 KB Output is correct
18 Correct 8 ms 336 KB Output is correct
19 Correct 20 ms 336 KB Output is correct
20 Correct 277 ms 356 KB Output is correct
21 Correct 259 ms 344 KB Output is correct
22 Correct 272 ms 348 KB Output is correct
23 Correct 292 ms 344 KB Output is correct
24 Correct 262 ms 344 KB Output is correct
25 Correct 47 ms 208 KB Output is correct
26 Correct 275 ms 340 KB Output is correct
27 Correct 265 ms 348 KB Output is correct
28 Correct 259 ms 336 KB Output is correct
29 Correct 269 ms 344 KB Output is correct
30 Correct 262 ms 340 KB Output is correct
31 Correct 285 ms 344 KB Output is correct
32 Correct 255 ms 356 KB Output is correct
33 Correct 260 ms 344 KB Output is correct
34 Correct 262 ms 344 KB Output is correct
35 Correct 261 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 81 ms 336 KB Output is correct
3 Correct 60 ms 344 KB Output is correct
4 Correct 34 ms 340 KB Output is correct
5 Correct 57 ms 344 KB Output is correct
6 Correct 9 ms 336 KB Output is correct
7 Correct 45 ms 344 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 13 ms 364 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 11 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 46 ms 336 KB Output is correct
14 Correct 31 ms 464 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 136 ms 336 KB Output is correct
17 Correct 19 ms 336 KB Output is correct
18 Correct 8 ms 336 KB Output is correct
19 Correct 20 ms 336 KB Output is correct
20 Correct 277 ms 356 KB Output is correct
21 Correct 259 ms 344 KB Output is correct
22 Correct 272 ms 348 KB Output is correct
23 Correct 292 ms 344 KB Output is correct
24 Correct 262 ms 344 KB Output is correct
25 Correct 47 ms 208 KB Output is correct
26 Correct 275 ms 340 KB Output is correct
27 Correct 265 ms 348 KB Output is correct
28 Correct 259 ms 336 KB Output is correct
29 Correct 269 ms 344 KB Output is correct
30 Correct 262 ms 340 KB Output is correct
31 Correct 285 ms 344 KB Output is correct
32 Correct 255 ms 356 KB Output is correct
33 Correct 260 ms 344 KB Output is correct
34 Correct 262 ms 344 KB Output is correct
35 Correct 261 ms 344 KB Output is correct
36 Execution timed out 4067 ms 2216 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4054 ms 3268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4056 ms 1104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 81 ms 336 KB Output is correct
3 Correct 60 ms 344 KB Output is correct
4 Correct 34 ms 340 KB Output is correct
5 Correct 57 ms 344 KB Output is correct
6 Correct 9 ms 336 KB Output is correct
7 Correct 45 ms 344 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 13 ms 364 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 11 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 46 ms 336 KB Output is correct
14 Correct 31 ms 464 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 136 ms 336 KB Output is correct
17 Correct 19 ms 336 KB Output is correct
18 Correct 8 ms 336 KB Output is correct
19 Correct 20 ms 336 KB Output is correct
20 Correct 277 ms 356 KB Output is correct
21 Correct 259 ms 344 KB Output is correct
22 Correct 272 ms 348 KB Output is correct
23 Correct 292 ms 344 KB Output is correct
24 Correct 262 ms 344 KB Output is correct
25 Correct 47 ms 208 KB Output is correct
26 Correct 275 ms 340 KB Output is correct
27 Correct 265 ms 348 KB Output is correct
28 Correct 259 ms 336 KB Output is correct
29 Correct 269 ms 344 KB Output is correct
30 Correct 262 ms 340 KB Output is correct
31 Correct 285 ms 344 KB Output is correct
32 Correct 255 ms 356 KB Output is correct
33 Correct 260 ms 344 KB Output is correct
34 Correct 262 ms 344 KB Output is correct
35 Correct 261 ms 344 KB Output is correct
36 Execution timed out 4067 ms 2216 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4026 ms 2148 KB Time limit exceeded
2 Halted 0 ms 0 KB -