Submission #1035064

#TimeUsernameProblemLanguageResultExecution timeMemory
1035064irmuunRadio Towers (IOI22_towers)C++17
0 / 100
4016 ms2768 KiB
#include<bits/stdc++.h> #include "towers.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int n; vector<int>h; vector<pair<int,int>>v; vector<bool>used; void init(int N,vector<int>H){ n=N; h=H; used.resize(n); for(int i=0;i<n;i++){ v.pb({H[i],i}); } sort(all(h)); } int max_towers(int L,int R,int D){ fill(all(used),0); int ans=0; for(auto [x,i]:v){ if(x<L||x>R) continue; bool add=true; int mx=0; for(int j=i-1;j>=L;j--){ if(used[j]){ if(mx<x+D){ add=false; } } mx=max(mx,h[j]); } mx=0; for(int j=i+1;j<=R;j++){ if(used[j]){ if(mx<x+D){ add=false; } } mx=max(mx,h[j]); } if(add){ ans++; used[i]=true; } } 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...