# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889421 | htphong0909 | Global Warming (NOI13_gw) | C++17 | 0 ms | 0 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>
using namespace std;
int gw(int N, int *H)
{
vector <int> ed;
for (int i = 1; i < N; i++) ed.emplace_back(min(H[i], H[i - 1]));
sort(H, H + N);
sort(ed.begin(), ed.end());
int p = -1;
int ans = 0;
for (int i = 0; i < N - 1; i++)
{
while (p + 1 < N && H[p + 1] <= ed[i]) p++;
ans = max(ans, 1 + i - p);
}
return ans;
}