Submission #680598

#TimeUsernameProblemLanguageResultExecution timeMemory
680598anonimyGlobal Warming (NOI13_gw)C++14
40 / 40
246 ms25452 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 ((ind == 0 || (!used[ind - 1])) && (ind == n - 1 || (!used[ind + 1]))) curr++; if (ind && ind < n - 1 && used[ind - 1] && used[ind + 1]) curr--; if (i == n - 1 || heights[i].first > heights[i + 1].first) 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...