Submission #781977

#TimeUsernameProblemLanguageResultExecution timeMemory
781977FEDIKUSRadio Towers (IOI22_towers)C++17
11 / 100
4101 ms4240 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; const int maxn=1e5+10; int n; int h[maxn]; void init(int _n, vector<int> _h) { n=_n; for(int i=0;i<n;i++) h[i]=_h[i]; } int resi(int l,int r,int d,int naj=1e9+10){ if(r<l) return 0; pair<int,int> maxi={-1,-1}; int klk=0; for(int i=l;i<=r;i++){ if(h[i]<=naj) klk++; maxi=max(maxi,{h[i],i}); } return max(resi(l,maxi.second-1,d,maxi.first-d)+resi(maxi.second+1,r,d,maxi.first-d),int(klk>0)); } int max_towers(int l, int r, int d) { return resi(l,r,d); }
#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...