Submission #1070604

# Submission time Handle Problem Language Result Execution time Memory
1070604 2024-08-22T15:52:32 Z Boas Radio Towers (IOI22_towers) C++17
11 / 100
4000 ms 2056 KB
#include "towers.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;

#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
#define INF ((int64_t)(4e18 + 1))
#define INF32 ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define F first
#define S second
#define var const auto &
#define foreach(l) for (var e : l)

typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;

vi h;
int n;

void init(int N, vi H)
{
  h = H;
  n = N;
}

int max_towers(int L, int R, int D)
{
  vi dp(R + 1, 1);
  vi maxDP(R + 1, 1);
  for (int i = R - 2; i >= L; i--)
  {
    int maxSoFar = 0;
    for (int j = i + 1; j <= R; j++)
    {
      maxSoFar = max(maxSoFar, h[j]);
      if (maxSoFar - max(h[i], h[j]) >= D)
      {
        dp[i] = maxDP[j] + 1;
        break;
        // was het probleem>??!!
      }
    }
    maxDP[i] = max(dp[i], maxDP[i + 1]);
  }
  return *max_element(ALL(dp));
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4050 ms 1276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 2 ms 436 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 2 ms 436 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 18 ms 1112 KB Output is correct
37 Correct 488 ms 1868 KB Output is correct
38 Correct 44 ms 1744 KB Output is correct
39 Correct 483 ms 1488 KB Output is correct
40 Correct 29 ms 1424 KB Output is correct
41 Correct 1728 ms 1964 KB Output is correct
42 Correct 9 ms 1488 KB Output is correct
43 Correct 1312 ms 1744 KB Output is correct
44 Correct 98 ms 1488 KB Output is correct
45 Correct 11 ms 1368 KB Output is correct
46 Correct 9 ms 1488 KB Output is correct
47 Correct 9 ms 1600 KB Output is correct
48 Correct 17 ms 1700 KB Output is correct
49 Correct 9 ms 1488 KB Output is correct
50 Correct 245 ms 1600 KB Output is correct
51 Correct 383 ms 1716 KB Output is correct
52 Correct 11 ms 1996 KB Output is correct
53 Correct 10 ms 2000 KB Output is correct
54 Correct 10 ms 2000 KB Output is correct
55 Execution timed out 4070 ms 1744 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4075 ms 2056 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4050 ms 1048 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 344 KB Output is correct
30 Correct 2 ms 436 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 18 ms 1112 KB Output is correct
37 Correct 488 ms 1868 KB Output is correct
38 Correct 44 ms 1744 KB Output is correct
39 Correct 483 ms 1488 KB Output is correct
40 Correct 29 ms 1424 KB Output is correct
41 Correct 1728 ms 1964 KB Output is correct
42 Correct 9 ms 1488 KB Output is correct
43 Correct 1312 ms 1744 KB Output is correct
44 Correct 98 ms 1488 KB Output is correct
45 Correct 11 ms 1368 KB Output is correct
46 Correct 9 ms 1488 KB Output is correct
47 Correct 9 ms 1600 KB Output is correct
48 Correct 17 ms 1700 KB Output is correct
49 Correct 9 ms 1488 KB Output is correct
50 Correct 245 ms 1600 KB Output is correct
51 Correct 383 ms 1716 KB Output is correct
52 Correct 11 ms 1996 KB Output is correct
53 Correct 10 ms 2000 KB Output is correct
54 Correct 10 ms 2000 KB Output is correct
55 Execution timed out 4070 ms 1744 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4050 ms 1276 KB Time limit exceeded
2 Halted 0 ms 0 KB -