# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
516317 | Jomnoi | Global Warming (NOI13_gw) | C++17 | 270 ms | 22524 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 <bits/stdc++.h>
#define DEBUG 0
using namespace std;
const int N = 1e6 + 10;
int parent[N];
bool appeared[N];
int root(int u) {
if(u == parent[u]) {
return u;
}
return parent[u] = root(parent[u]);
}
int main() {
int n;
scanf(" %d", &n);
for(int i = 1; i <= n; i++) {
parent[i] = i;
}
vector <pair <int, int>> vec;
for(int i = 1; i <= n; i++) {
int h;
scanf(" %d", &h);
vec.emplace_back(h, i);
}
sort(vec.rbegin(), vec.rend());
int cmp = 0, ans = 0;
for(auto [h, i] : vec) {
cmp++;
appeared[i] = true;
if(appeared[i - 1] == true) {
cmp--;
parent[root(i)] = root(i - 1);
}
if(appeared[i + 1] == true) {
cmp--;
parent[root(i)] = root(i + 1);
}
ans = max(ans, cmp);
}
printf("%d", ans);
return 0;
}
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... |