# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889421 | 2023-12-19T16:11:22 Z | htphong0909 | Global Warming (NOI13_gw) | C++17 | 0 ms | 0 KB |
#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; }