Submission #1062063

#TimeUsernameProblemLanguageResultExecution timeMemory
1062063MarwenElarbiRadio Towers (IOI22_towers)C++17
0 / 100
4073 ms2484 KiB
#include <bits/stdc++.h> using namespace std; #include "towers.h" #define pb push_back #define ll long long #define fi first #define se second const int nax=1e5+5; int n; vector<int> tab; void init(int N, std::vector<int> H) { n=N; for (int i = 0; i < N; ++i) { tab.pb(H[i]); } } int max_towers(int L, int R, int D){ int dp[n]; int ans=0; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; int cnt=0; for (int i = L; i <= R; ++i) { dp[i]=cnt+1; while(!pq.empty()){ auto cur=pq.top(); if(tab[i]-cur.fi>=D){ pq.pop(); cnt=max(cnt,cur.se); }else break; } pq.push({tab[i],dp[i]}); ans=max(ans,dp[i]); } 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...