# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38943 | cheater2k | Global Warming (NOI13_gw) | C++14 | 299 ms | 15480 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;
const int N = 1e6 + 5;
int n;
vector< pair<int,int> > vec;
int ans, cur;
bool check[N];
void add(int pos) {
check[pos] = 1;
if (pos > 1 && pos < n && check[pos - 1] && check[pos + 1]) {
--cur; return;
}
bool flag = false;
flag |= (pos > 1 && check[pos - 1]);
flag |= (pos < n && check[pos + 1]);
if (!flag) ++cur;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i) {
int x; cin >> x;
vec.push_back(make_pair(x, i));
}
sort(vec.begin(), vec.end(), greater< pair<int,int> >());
for (int i = 0; i < vec.size(); ) {
int height = vec[i].first;
while(i < vec.size() && vec[i].first == height) {
add(vec[i].second);
++i;
}
ans = max(ans, cur);
}
cout << ans << endl;
}
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... |