# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1081945 | farica | Radio Towers (IOI22_towers) | C++17 | 4035 ms | 5672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
int n,sub1=1,idx=0;
vector<int> h;
void init(int N, vector<int> H) {
h.clear();
sub1 = 1;
n = N;
for(auto x : H)
h.push_back(x);
int ok=1;
for(int i=0; i<H.size()-1; i++) {
if(ok and H[i] > H[i+1]) {
ok=0;
idx = i;
}
if(!ok and H[i] < H[i+1])
sub1=0;
}
}
int max_towers(int L, int R, int D) {
if(sub1) {
if(idx > L and idx < R and (h[L]+D) <= h[idx] and (h[R]+D) <= h[idx])
return 2;
else
return 1;
}
int ans=1;
set<int>s;
map<int,int>m;
for(int i=L; i<=R; i++) {
auto it = s.lower_bound(h[i]+D);
m[h[i]] = ans;
if(it != s.end()) ans = max(ans, m[*it]+1);
while(!s.empty() && *(s.begin()) < h[i]) s.erase(s.begin());
s.insert(h[i]);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |