답안 #824994

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824994 2023-08-14T12:59:40 Z PixelCat 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 1524 KB
#include "towers.h"

#ifdef NYAOWO
#include "stub.cpp"
#endif

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second 
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;

inline void chmax(int &x, int val) { x = max(x, val); }

const int MAXN = 100'000;

// #define L(id) ((id) * 2 + 1)
// #define R(id) ((id) * 2 + 2)
// struct SegTree {
//     int mx[MAXN * 4 + 10];
//     void build() {
//         memset(mx, 0, sizeof(mx));
//     }
//     void upd(int id, int l, int r, int pos, int val) {
//         if(l == r) {
//             mx[id] = 
//         }
//     }
// } seg;

int n;
int h[MAXN + 10];
int dp1[MAXN + 10];
int dp2[MAXN + 10];

void init(int N, std::vector<int> H) {
    n = N;
    For(i, 0, n - 1) h[i] = H[i];
}

int max_towers(int L, int R, int D) {
    int ans = 0;
    For(i, L, R) {
        dp1[i] = 1;
        dp2[i] = 0;
        For(j, L, i - 1) {
            if(h[i] - D >= h[j]) {
                chmax(dp2[i], dp1[j]);
            } else if(h[i] + D <= h[j]) {
                chmax(dp1[i], dp2[j] + 1);
            }
        }
        chmax(ans, dp1[i]);
    }
    return ans;
}

/*

7 3
10 20 60 40 50 30 70
1 5 10
2 2 100
0 6 17

3
1
2

*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4059 ms 1228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 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 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 5 ms 336 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 7 ms 340 KB Output is correct
28 Correct 4 ms 296 KB Output is correct
29 Correct 4 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 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 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 5 ms 336 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 7 ms 340 KB Output is correct
28 Correct 4 ms 296 KB Output is correct
29 Correct 4 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Correct 673 ms 976 KB Output is correct
37 Correct 977 ms 1460 KB Output is correct
38 Correct 408 ms 1444 KB Output is correct
39 Correct 502 ms 1428 KB Output is correct
40 Correct 237 ms 1444 KB Output is correct
41 Execution timed out 4059 ms 1484 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4032 ms 1524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4009 ms 780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 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 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 5 ms 336 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 7 ms 340 KB Output is correct
28 Correct 4 ms 296 KB Output is correct
29 Correct 4 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Correct 673 ms 976 KB Output is correct
37 Correct 977 ms 1460 KB Output is correct
38 Correct 408 ms 1444 KB Output is correct
39 Correct 502 ms 1428 KB Output is correct
40 Correct 237 ms 1444 KB Output is correct
41 Execution timed out 4059 ms 1484 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4059 ms 1228 KB Time limit exceeded
2 Halted 0 ms 0 KB -