Submission #680596

#TimeUsernameProblemLanguageResultExecution timeMemory
680596anonimyGlobal Warming (NOI13_gw)C++14
6 / 40
255 ms25444 KiB
#include <iostream> #include <algorithm> #include <vector> #include <functional> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<pll> heights(n); for (ll i = 0; i < n; i++) { cin >> heights[i].first; heights[i].second = i; } sort(heights.begin(), heights.end(), greater<pll>()); vector<bool> used(n, false); ll ans = 0, curr = 0; for (ll i = 0; i < n; i++) { ll ind = heights[i].second; used[ind] = true; if (i < n - 1 && heights[i].first == heights[i + 1].first) continue; if ((ind == 0 || (!used[ind - 1])) && (ind == n - 1 || (!used[ind + 1]))) curr++; if (ind && ind < n - 1 && used[ind - 1] && used[ind + 1]) curr--; ans = max(ans, curr); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...