Submission #628867

# Submission time Handle Problem Language Result Execution time Memory
628867 2022-08-13T18:44:59 Z kkkkkkkk Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
 
using namespace std;
 
vector<int> height;
int N,k=0;
 
void init(int n,vector<int> H)
{
    N=n;
    height=H;
}
 
int max_towers(int l,int r,int d)
{
    int res=1;
    vector<int> dp(n,1);
    for (int i=l;i<=r;i++)
    {
        int tower=height[i-1];
        for (int j=i-2;j>=l;j--)
        {
            if (tower-d>=height[j]&&tower-d>=height[i])
                dp[i]=max(dp[i],dp[j]+1);
            tower=max(tower,height[j]);
        }
        res=max(dp[i],res);
    }
    return res;
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:17:20: error: 'n' was not declared in this scope
   17 |     vector<int> dp(n,1);
      |                    ^