답안 #1072482

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072482 2024-08-23T19:51:32 Z vjudge1 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 6380 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;
using vi = vector <int>;

ll n, k;
vll ve;
void init (int n, vi ve) {
    ::n = n;
    k = 0;
    ::ve = vll(ve.begin(), ve.end());
    while (ve[k] < ve[k+1]) k++;
}

const ll MAXN = 1E5+16;
ll dp[2][MAXN];
ll dpPs[2][MAXN];
// dp[0] low
// dp[1] up
int max_towers (int ql, int qr, int d) {
    // fill(dp+ql, dp+qr+1, 0);
    // cerr << d << '\n';
    // for (ll i = ql; i <= qr; i++) {
    //     ii maxN = { 0, -16 };
    //     dp[i] = 1;
    //     for (ll j = i-1; j >= ql; j--) {
    //         if (ve[i] <= maxN.first-d)
    //             if (ve[j] <= maxN.first-d) {
    //                 dp[i] = max(dp[i], dp[j]+1);
    //             }
    //         maxN = max(maxN, ii{ ve[j], j });
    //     }
    //     // cerr << ve[i] << ": " << dp[i] << '\n';
    // }
    // return *max_element(dp+ql, dp+qr+1);


    // fill(dp+ql, dp+qr+1, 0);
    deque <ii> dqUp, dqDw;
    // dqUp sorted increasing
    // dqDw sorted decreasing
    for (ll i = ql; i <= qr; i++) {
        dp[0][i] = 1;
        dp[1][i] = 0;
        while (dqUp.size() && dqUp.front().first < ve[i]) dqUp.pop_front();
        while (dqDw.size() && dqDw.front().first > ve[i]) dqDw.pop_front();
        // if (j < dq.size()) dp[i] = max(dp[i], dq[j].second+1);
        // cerr << ve[i] << ": " << dp[i] << '\n';
        // cerr << "j " << j << "  ";
        // for (auto [v1, v2] : dqUp) cerr << v1 << ' ' << v2 << "  ";
        // cerr << '\n';
        // for (auto [v1, v2] : dqDw) cerr << v1 << ' ' << v2 << "  ";
        // cerr << '\n';
        // cerr << '\n';
        for (auto [v, j] : dqUp) {
            if (ve[i] > ve[j]-d) continue;
            dp[0][i] = max(dp[0][i], dpPs[1][j]+1);
            break;
        }
        for (auto [v, j] : dqDw) {
            if (ve[i] < ve[j]+d) continue;
            dp[1][i] = max(dp[1][i], dpPs[0][j]+1);
            break;
        }
        dpPs[1][i] = max(dp[1][i], dqUp.size() ? dpPs[1][dqUp.front().second] : 0);
        dqUp.push_front({ ve[i], i });
        dpPs[0][i] = max(dp[0][i], dqDw.size() ? dpPs[0][dqDw.front().second] : 0);
        dqDw.push_front({ ve[i], i });
        // ll j = ll(lower_bound(dqUp.begin(), dqUp.end(), ii{ ve[i]+d, 0 }) - dq.begin())+1;
        // for (ll j = i-1; j >= ql; j--) {
        //     if (ve[i] <= maxN.first-d)
        //         if (ve[j] <= maxN.first-d) dp[i] = max(dp[i], dp[j]+1);
        //     maxN = max(maxN, ii{ ve[j], j });
        // }
    }
    return (*max_element(dp[0]+ql, dp[0]+qr+1)+1)/2;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4069 ms 4608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 2 ms 2392 KB Output is correct
33 Correct 2 ms 2392 KB Output is correct
34 Correct 2 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 2 ms 2392 KB Output is correct
33 Correct 2 ms 2392 KB Output is correct
34 Correct 2 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 11 ms 3416 KB Output is correct
37 Correct 11 ms 3792 KB Output is correct
38 Correct 9 ms 3756 KB Output is correct
39 Correct 10 ms 3792 KB Output is correct
40 Correct 14 ms 3792 KB Output is correct
41 Correct 13 ms 4392 KB Output is correct
42 Correct 10 ms 3536 KB Output is correct
43 Correct 784 ms 4808 KB Output is correct
44 Correct 107 ms 3792 KB Output is correct
45 Correct 11 ms 3536 KB Output is correct
46 Correct 12 ms 3536 KB Output is correct
47 Correct 11 ms 3860 KB Output is correct
48 Correct 10 ms 3792 KB Output is correct
49 Correct 9 ms 3536 KB Output is correct
50 Correct 13 ms 4124 KB Output is correct
51 Correct 14 ms 4560 KB Output is correct
52 Correct 17 ms 4560 KB Output is correct
53 Correct 12 ms 4560 KB Output is correct
54 Correct 12 ms 4656 KB Output is correct
55 Correct 14 ms 6380 KB Output is correct
56 Correct 12 ms 5328 KB Output is correct
57 Correct 20 ms 4544 KB Output is correct
58 Correct 14 ms 4560 KB Output is correct
59 Correct 14 ms 4704 KB Output is correct
60 Correct 12 ms 4560 KB Output is correct
61 Correct 12 ms 4552 KB Output is correct
62 Correct 13 ms 4552 KB Output is correct
63 Correct 13 ms 4560 KB Output is correct
64 Execution timed out 4074 ms 6088 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4054 ms 4724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4025 ms 3160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 2 ms 2392 KB Output is correct
33 Correct 2 ms 2392 KB Output is correct
34 Correct 2 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 11 ms 3416 KB Output is correct
37 Correct 11 ms 3792 KB Output is correct
38 Correct 9 ms 3756 KB Output is correct
39 Correct 10 ms 3792 KB Output is correct
40 Correct 14 ms 3792 KB Output is correct
41 Correct 13 ms 4392 KB Output is correct
42 Correct 10 ms 3536 KB Output is correct
43 Correct 784 ms 4808 KB Output is correct
44 Correct 107 ms 3792 KB Output is correct
45 Correct 11 ms 3536 KB Output is correct
46 Correct 12 ms 3536 KB Output is correct
47 Correct 11 ms 3860 KB Output is correct
48 Correct 10 ms 3792 KB Output is correct
49 Correct 9 ms 3536 KB Output is correct
50 Correct 13 ms 4124 KB Output is correct
51 Correct 14 ms 4560 KB Output is correct
52 Correct 17 ms 4560 KB Output is correct
53 Correct 12 ms 4560 KB Output is correct
54 Correct 12 ms 4656 KB Output is correct
55 Correct 14 ms 6380 KB Output is correct
56 Correct 12 ms 5328 KB Output is correct
57 Correct 20 ms 4544 KB Output is correct
58 Correct 14 ms 4560 KB Output is correct
59 Correct 14 ms 4704 KB Output is correct
60 Correct 12 ms 4560 KB Output is correct
61 Correct 12 ms 4552 KB Output is correct
62 Correct 13 ms 4552 KB Output is correct
63 Correct 13 ms 4560 KB Output is correct
64 Execution timed out 4074 ms 6088 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4069 ms 4608 KB Time limit exceeded
2 Halted 0 ms 0 KB -