Submission #1035065

# Submission time Handle Problem Language Result Execution time Memory
1035065 2024-07-26T03:42:46 Z irmuun Radio Towers (IOI22_towers) C++17
11 / 100
4000 ms 2768 KB
#include<bits/stdc++.h>
#include "towers.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int n;
vector<int>h;
vector<pair<int,int>>v;
vector<bool>used;

void init(int N,vector<int>H){
    n=N; h=H;
    used.resize(n);
    for(int i=0;i<n;i++){
        v.pb({H[i],i});
    }
    sort(all(v));
}
int max_towers(int L,int R,int D){
    fill(all(used),0);
    int ans=0;
    for(auto [x,i]:v){
        if(i<L||i>R) continue;
        bool add=true;
        int mx=0;
        for(int j=i-1;j>=L;j--){
            if(used[j]){
                if(mx<x+D){
                    add=false;
                }
            }
            mx=max(mx,h[j]);
        }
        mx=0;
        for(int j=i+1;j<=R;j++){
            if(used[j]){
                if(mx<x+D){
                    add=false;
                }
            }
            mx=max(mx,h[j]);
        }
        if(add){
            ans++;
            used[i]=true;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 1748 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 3 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 5 ms 344 KB Output is correct
23 Correct 4 ms 484 KB Output is correct
24 Correct 4 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 5 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 5 ms 344 KB Output is correct
30 Correct 8 ms 484 KB Output is correct
31 Correct 5 ms 344 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Correct 4 ms 344 KB Output is correct
34 Correct 4 ms 488 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 5 ms 344 KB Output is correct
23 Correct 4 ms 484 KB Output is correct
24 Correct 4 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 5 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 5 ms 344 KB Output is correct
30 Correct 8 ms 484 KB Output is correct
31 Correct 5 ms 344 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Correct 4 ms 344 KB Output is correct
34 Correct 4 ms 488 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 686 ms 1748 KB Output is correct
37 Correct 1680 ms 2768 KB Output is correct
38 Correct 281 ms 2768 KB Output is correct
39 Correct 1004 ms 2768 KB Output is correct
40 Correct 227 ms 2768 KB Output is correct
41 Execution timed out 4090 ms 2764 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 2768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4059 ms 1112 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 3 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 5 ms 344 KB Output is correct
23 Correct 4 ms 484 KB Output is correct
24 Correct 4 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 5 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 5 ms 344 KB Output is correct
30 Correct 8 ms 484 KB Output is correct
31 Correct 5 ms 344 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Correct 4 ms 344 KB Output is correct
34 Correct 4 ms 488 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 686 ms 1748 KB Output is correct
37 Correct 1680 ms 2768 KB Output is correct
38 Correct 281 ms 2768 KB Output is correct
39 Correct 1004 ms 2768 KB Output is correct
40 Correct 227 ms 2768 KB Output is correct
41 Execution timed out 4090 ms 2764 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 1748 KB Time limit exceeded
2 Halted 0 ms 0 KB -