Submission #833701

# Submission time Handle Problem Language Result Execution time Memory
833701 2023-08-22T08:01:58 Z Trumling Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 3136 KB
#include "towers.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define all(x) x.begin(),x.end()
typedef long long ll;
#define pb push_back
#define INF 9999999999999999
ll n;
vector<ll>h;
void init(int N, vector<int> H) 
{
  n=N;
  for(int i=0;i<N;i++)
    h.pb(H[i]);
    
}

int max_towers(int L, int R, int D) 
{
  vector<pair<ll,ll>>v(n);

    for(int i=L;i<=R;i++)
      v[i]={1,h[i]};

    for(int i=0;i<n;i++)
    {
      ll maxi=h[i];
      for(int j=i-1;j>=0;j--)
      {
        maxi=max(maxi,h[j]);

        if(maxi-D>=h[j] && maxi-D>=h[i])
        {
          if(v[i].F<v[j].F+1)
            v[i]={v[j].F+1,max(h[i],v[j].S)};
          else if(v[i].F==v[j].F+1)
            v[i].S=min(v[i].S,max(v[j].S,h[i]));
          

        }
      }
    }

    ll maxi=0;
    for(int i=0;i<n;i++)
    maxi=max(maxi,v[i].F);


    return maxi;

      
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4016 ms 2072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '130'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '130'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4046 ms 3136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4029 ms 1168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '130'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4016 ms 2072 KB Time limit exceeded
2 Halted 0 ms 0 KB -