Submission #1062060

#TimeUsernameProblemLanguageResultExecution timeMemory
1062060MarwenElarbiRadio Towers (IOI22_towers)C++17
0 / 100
4085 ms2792 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>> pq; int cnt=0; for (int i = L; i <= R; ++i) { dp[i]=1; while(!pq.empty()){ auto cur=pq.top(); if(tab[i]-cur.fi>=D){ pq.pop(); cnt=max(cnt,cur.se); }else break; } dp[i]=max(dp[i],cnt+1); 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...