Submission #705596

# Submission time Handle Problem Language Result Execution time Memory
705596 2023-03-04T18:01:43 Z danikoynov Radio Towers (IOI22_towers) C++17
11 / 100
4000 ms 1572 KB
#include "towers.h"

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;

int n, h[maxn];
void init(int N, std::vector<int> H)
{
    n = N;
    for (int i = 0; i < n; i ++)
        h[i] = H[i];
}

int par[maxn], rnk[maxn];

int find_leader(int v)
{
    return (v == par[v]) ? v : par[v] = find_leader(par[v]);
}

void unite(int v, int u)
{
    v = find_leader(v);
    u = find_leader(u);
    if (v == u)
        return;

    if (rnk[v] < rnk[u])
        swap(v, u);
    rnk[v] += rnk[u];
    par[u] = v;
}

int dp[maxn];
int max_towers(int L, int R, int D)
{
    for (int i = L; i <= R; i ++)
    {
        dp[i] = 1;
    }

    for (int i = L; i <= R; i ++)
    {
        int max_tower = 0;
        for (int j = i - 1; j >= L; j --)
        {
            if (max_tower - D >= h[i] && max_tower - D >= h[j])
                dp[i] = max(dp[i], dp[j] + 1);
            max_tower = max(max_tower, h[j]);
        }
    }

    int ans = 0;
    for (int i = L; i <= R; i ++)
        ans = max(ans, dp[i]);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4010 ms 980 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 2 ms 336 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 8 ms 300 KB Output is correct
21 Correct 8 ms 336 KB Output is correct
22 Correct 7 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 4 ms 336 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 4 ms 336 KB Output is correct
27 Correct 5 ms 208 KB Output is correct
28 Correct 4 ms 208 KB Output is correct
29 Correct 4 ms 208 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 332 KB Output is correct
32 Correct 4 ms 208 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 8 ms 300 KB Output is correct
21 Correct 8 ms 336 KB Output is correct
22 Correct 7 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 4 ms 336 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 4 ms 336 KB Output is correct
27 Correct 5 ms 208 KB Output is correct
28 Correct 4 ms 208 KB Output is correct
29 Correct 4 ms 208 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 332 KB Output is correct
32 Correct 4 ms 208 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
36 Correct 521 ms 976 KB Output is correct
37 Correct 1078 ms 1452 KB Output is correct
38 Correct 258 ms 1456 KB Output is correct
39 Correct 592 ms 1572 KB Output is correct
40 Correct 235 ms 1448 KB Output is correct
41 Execution timed out 4051 ms 1360 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4010 ms 1448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4025 ms 676 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 2 ms 336 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 8 ms 300 KB Output is correct
21 Correct 8 ms 336 KB Output is correct
22 Correct 7 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 4 ms 336 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 4 ms 336 KB Output is correct
27 Correct 5 ms 208 KB Output is correct
28 Correct 4 ms 208 KB Output is correct
29 Correct 4 ms 208 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 332 KB Output is correct
32 Correct 4 ms 208 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
36 Correct 521 ms 976 KB Output is correct
37 Correct 1078 ms 1452 KB Output is correct
38 Correct 258 ms 1456 KB Output is correct
39 Correct 592 ms 1572 KB Output is correct
40 Correct 235 ms 1448 KB Output is correct
41 Execution timed out 4051 ms 1360 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4010 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -