Submission #954207

# Submission time Handle Problem Language Result Execution time Memory
954207 2024-03-27T11:55:39 Z tleSquared Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 1592 KB
#include <bits/stdc++.h>
#define INF 1e18

using namespace std;

vector<int> H;
vector<bool> seg;
int N;

bool ok(int l, int r, int d)
{
    for (int i = l+1; i < r; i++)
    {
        if (max(H[l], H[r]) <= H[i]-d) return true;
    }
    return false;
}

void init(int n, vector<int> h)
{
    H = h;
    N = n;
}

int max_towers(int L, int R, int D)
{
    int ans = 1;
    for (int last = L; last <= R; last++)
    {
        int cur_ans = 1;
        for (int i = last+2; i <= R; i++)
        {
            if (ok(last, i, D))
            {
                cur_ans++;
                last = i++;
            }
        }
        ans = max(ans, cur_ans);
    }

    return ans;
}

// int main()
// {
//     init(7, {10, 20, 60, 40, 50, 30, 70});

//     cout << max_towers(1, 5, 10) << endl; // Ans:- 3

//     cout << max_towers(2, 2, 100) << endl; // Ans:- 1

//     cout << max_towers(0, 6, 17) << endl; // Ans:- 2

//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Execution timed out 4011 ms 932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '12'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '12'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4072 ms 1592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4030 ms 516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '12'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4011 ms 932 KB Time limit exceeded
2 Halted 0 ms 0 KB -