Submission #1245113

#TimeUsernameProblemLanguageResultExecution timeMemory
1245113guanexRadio Towers (IOI22_towers)C++20
14 / 100
258 ms1820 KiB
#include "towers.h"

#include <vector>

#include<bits/stdc++.h>

using namespace std;

vector<int> pref;
vector<int> h;

void init(int N, std::vector<int> H) {
  if(N == 1){
    return;
  }
  pref.assign(N, 0);
  if(H[0] < H[1]){
    pref[0] = 1;
  }
  if(H[N-1] < H[N-2]){
    pref[N-1] = 1;
  }
  for(int i = 1; i < N-1; ++i){
    if(H[i] < H[i-1] && H[i] < H[i+1]){
      pref[i]++;
    }
  }
  for(int i = 1; i < N; ++i){
    pref[i] += pref[i-1];
  }
  h = H;
}


int max_towers(int L, int R, int D) {
  if((int)pref.size() == 0 || L == R){
    return 1;
  }
  int ans = 0;
  if(h[L] < h[L+1]){
    ans++;
  }
  if(h[R] < h[R-1]){
    ans++;
  }
  ans += pref[R-1] - pref[L];
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...