답안 #629484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629484 2022-08-14T14:21:05 Z arnold518 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 5428 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, H[MAXN+10];

struct SEG
{
    int tree[MAXN*4+10];
    void init(int node, int tl, int tr)
    {
        if(tl==tr)
        {
            tree[node]=H[tl];
            return;
        }
        int mid=tl+tr>>1;
        init(node*2, tl, mid);
        init(node*2+1, mid+1, tr);
        tree[node]=max(tree[node*2], tree[node*2+1]);
    }
    int query(int node, int tl, int tr, int l, int r)
    {
        if(r<tl || tr<l) return 0;
        if(l<=tl && tr<=r) return tree[node];
        int mid=tl+tr>>1;
        return max(query(node*2, tl, mid, l, r), query(node*2+1, mid+1, tr, l, r));
    }
}seg;

void init(int _N, vector<int> _H)
{
    N=_N;
    for(int i=1; i<=N; i++) H[i]=_H[i-1];
    seg.init(1, 1, N);
}

int max_towers(int L, int R, int D)
{
    L++; R++;

    vector<pii> V;
    vector<int> V2;
    for(int i=L; i<=R; i++) V.push_back({H[i], i});
    sort(V.begin(), V.end());
    
    set<int> S;
    for(auto it : V)
    {
        auto pt=S.lower_bound(it.second);
        bool flag=true;
        if(pt!=S.end())
        {
            int l=it.second, r=*pt;
            if(seg.query(1, 1, N, l, r)-D<it.first) flag=false;
        }
        if(pt!=S.begin())
        {
            int l=*prev(pt), r=it.second;
            if(seg.query(1, 1, N, l, r)-D<it.first) flag=false;
        }
        if(flag) S.insert(it.second), V2.push_back(it.second);
    }
    return S.size();
}

Compilation message

towers.cpp: In member function 'void SEG::init(int, int, int)':
towers.cpp:23:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |         int mid=tl+tr>>1;
      |                 ~~^~~
towers.cpp: In member function 'int SEG::query(int, int, int, int, int)':
towers.cpp:32:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |         int mid=tl+tr>>1;
      |                 ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4010 ms 2500 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 344 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 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 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 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 384 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 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 344 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 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 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 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 384 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 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 18 ms 1728 KB Output is correct
37 Correct 36 ms 2848 KB Output is correct
38 Correct 20 ms 2476 KB Output is correct
39 Correct 28 ms 2504 KB Output is correct
40 Correct 18 ms 2376 KB Output is correct
41 Correct 76 ms 3648 KB Output is correct
42 Correct 18 ms 2468 KB Output is correct
43 Correct 20 ms 2956 KB Output is correct
44 Correct 21 ms 2480 KB Output is correct
45 Correct 11 ms 2476 KB Output is correct
46 Correct 11 ms 2376 KB Output is correct
47 Correct 31 ms 2968 KB Output is correct
48 Correct 24 ms 2752 KB Output is correct
49 Correct 16 ms 2472 KB Output is correct
50 Correct 23 ms 2464 KB Output is correct
51 Correct 18 ms 2864 KB Output is correct
52 Correct 74 ms 4676 KB Output is correct
53 Correct 85 ms 5428 KB Output is correct
54 Correct 81 ms 5388 KB Output is correct
55 Correct 25 ms 3616 KB Output is correct
56 Correct 36 ms 3612 KB Output is correct
57 Correct 67 ms 3620 KB Output is correct
58 Correct 79 ms 3756 KB Output is correct
59 Correct 73 ms 4116 KB Output is correct
60 Correct 103 ms 5408 KB Output is correct
61 Correct 99 ms 4972 KB Output is correct
62 Correct 83 ms 4380 KB Output is correct
63 Correct 74 ms 5012 KB Output is correct
64 Correct 23 ms 3624 KB Output is correct
65 Correct 24 ms 3624 KB Output is correct
66 Correct 37 ms 3648 KB Output is correct
67 Correct 21 ms 3612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4040 ms 4800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4046 ms 1656 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 344 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 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 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 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 384 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 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 18 ms 1728 KB Output is correct
37 Correct 36 ms 2848 KB Output is correct
38 Correct 20 ms 2476 KB Output is correct
39 Correct 28 ms 2504 KB Output is correct
40 Correct 18 ms 2376 KB Output is correct
41 Correct 76 ms 3648 KB Output is correct
42 Correct 18 ms 2468 KB Output is correct
43 Correct 20 ms 2956 KB Output is correct
44 Correct 21 ms 2480 KB Output is correct
45 Correct 11 ms 2476 KB Output is correct
46 Correct 11 ms 2376 KB Output is correct
47 Correct 31 ms 2968 KB Output is correct
48 Correct 24 ms 2752 KB Output is correct
49 Correct 16 ms 2472 KB Output is correct
50 Correct 23 ms 2464 KB Output is correct
51 Correct 18 ms 2864 KB Output is correct
52 Correct 74 ms 4676 KB Output is correct
53 Correct 85 ms 5428 KB Output is correct
54 Correct 81 ms 5388 KB Output is correct
55 Correct 25 ms 3616 KB Output is correct
56 Correct 36 ms 3612 KB Output is correct
57 Correct 67 ms 3620 KB Output is correct
58 Correct 79 ms 3756 KB Output is correct
59 Correct 73 ms 4116 KB Output is correct
60 Correct 103 ms 5408 KB Output is correct
61 Correct 99 ms 4972 KB Output is correct
62 Correct 83 ms 4380 KB Output is correct
63 Correct 74 ms 5012 KB Output is correct
64 Correct 23 ms 3624 KB Output is correct
65 Correct 24 ms 3624 KB Output is correct
66 Correct 37 ms 3648 KB Output is correct
67 Correct 21 ms 3612 KB Output is correct
68 Execution timed out 4040 ms 4800 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4010 ms 2500 KB Time limit exceeded
2 Halted 0 ms 0 KB -