답안 #774632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774632 2023-07-06T00:48:50 Z Magikarp4000 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 4972 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n' 
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;

const int MAXN = 1e5+5;
int n,l,r,d;
int h[MAXN], le[MAXN], ri[MAXN];
set<int> s;

bool check(int start) {
    FORR(i,start-1,-1) {
        if (s.count(i)) return 0;
        if (h[i] >= h[start]+d) return 1;
    }
    return 1;
}

bool check1(int start) {
    FOR(i,start+1,n) {
        if (s.count(i)) return 0;
        if (h[i] >= h[start]+d) return 1;
    }
    return 1;
}

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

int max_towers(int L, int R, int D) {
    s.clear();
    l = L, r = R, d = D;
    vector<PII> v;
    FOR(i,l,r+1) v.PB({h[i],i});
    sort(ALL(v));
    int vn = v.size();
    PQ<PII> pq;
    FOR(i,l,r+1) {
        while (!pq.empty() && -pq.top().F <= h[i]-d) {
            ri[pq.top().S] = i;
            pq.pop();
        }
        pq.push({-h[i],i});
    }
    while (!pq.empty()) {
        ri[pq.top().S] = n;
        pq.pop();
    }
    FORR(i,r,l-1) {
        while (!pq.empty() && -pq.top().F <= h[i]-d) {
            le[pq.top().S] = i;
            pq.pop();
        }
        pq.push({-h[i],i});
    }
    while (!pq.empty()) {
        le[pq.top().S] = -1;
        pq.pop();
    }
    // FOR(i,0,n) cout << le[i] << " ";
    // cout << ln;
    // FOR(i,0,n) cout << ri[i] << " ";
    // cout << ln;
    s.insert(-INF);
    s.insert(INF);
    FOR(i,0,vn) {
        int idx = v[i].S;
        auto it = s.lower_bound(idx);
        auto it1 = it;
        it1--;
        if (le[idx] > (*it1) && ri[idx] < (*it)) s.insert(idx);
    }
    return s.size()-2;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 2712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 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 208 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 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 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 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 208 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 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 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 17 ms 1340 KB Output is correct
37 Correct 22 ms 2120 KB Output is correct
38 Correct 19 ms 1480 KB Output is correct
39 Correct 25 ms 2100 KB Output is correct
40 Correct 13 ms 1520 KB Output is correct
41 Correct 44 ms 3516 KB Output is correct
42 Correct 9 ms 1360 KB Output is correct
43 Correct 18 ms 2804 KB Output is correct
44 Correct 13 ms 1456 KB Output is correct
45 Correct 10 ms 1440 KB Output is correct
46 Correct 10 ms 1488 KB Output is correct
47 Correct 19 ms 2140 KB Output is correct
48 Correct 14 ms 1856 KB Output is correct
49 Correct 10 ms 1440 KB Output is correct
50 Correct 11 ms 1792 KB Output is correct
51 Correct 14 ms 2496 KB Output is correct
52 Correct 40 ms 4196 KB Output is correct
53 Correct 41 ms 4972 KB Output is correct
54 Correct 49 ms 4896 KB Output is correct
55 Correct 21 ms 3476 KB Output is correct
56 Correct 22 ms 3772 KB Output is correct
57 Correct 49 ms 3564 KB Output is correct
58 Correct 61 ms 3872 KB Output is correct
59 Correct 50 ms 4028 KB Output is correct
60 Correct 45 ms 4888 KB Output is correct
61 Correct 51 ms 4780 KB Output is correct
62 Correct 55 ms 4284 KB Output is correct
63 Correct 51 ms 4784 KB Output is correct
64 Correct 32 ms 3760 KB Output is correct
65 Correct 26 ms 3484 KB Output is correct
66 Correct 27 ms 3780 KB Output is correct
67 Correct 27 ms 3484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4098 ms 4516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4019 ms 1652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 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 208 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 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 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 17 ms 1340 KB Output is correct
37 Correct 22 ms 2120 KB Output is correct
38 Correct 19 ms 1480 KB Output is correct
39 Correct 25 ms 2100 KB Output is correct
40 Correct 13 ms 1520 KB Output is correct
41 Correct 44 ms 3516 KB Output is correct
42 Correct 9 ms 1360 KB Output is correct
43 Correct 18 ms 2804 KB Output is correct
44 Correct 13 ms 1456 KB Output is correct
45 Correct 10 ms 1440 KB Output is correct
46 Correct 10 ms 1488 KB Output is correct
47 Correct 19 ms 2140 KB Output is correct
48 Correct 14 ms 1856 KB Output is correct
49 Correct 10 ms 1440 KB Output is correct
50 Correct 11 ms 1792 KB Output is correct
51 Correct 14 ms 2496 KB Output is correct
52 Correct 40 ms 4196 KB Output is correct
53 Correct 41 ms 4972 KB Output is correct
54 Correct 49 ms 4896 KB Output is correct
55 Correct 21 ms 3476 KB Output is correct
56 Correct 22 ms 3772 KB Output is correct
57 Correct 49 ms 3564 KB Output is correct
58 Correct 61 ms 3872 KB Output is correct
59 Correct 50 ms 4028 KB Output is correct
60 Correct 45 ms 4888 KB Output is correct
61 Correct 51 ms 4780 KB Output is correct
62 Correct 55 ms 4284 KB Output is correct
63 Correct 51 ms 4784 KB Output is correct
64 Correct 32 ms 3760 KB Output is correct
65 Correct 26 ms 3484 KB Output is correct
66 Correct 27 ms 3780 KB Output is correct
67 Correct 27 ms 3484 KB Output is correct
68 Execution timed out 4098 ms 4516 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 2712 KB Time limit exceeded
2 Halted 0 ms 0 KB -