Submission #1023158

#TimeUsernameProblemLanguageResultExecution timeMemory
1023158avighnaGlobal Warming (NOI13_gw)C++17
30 / 40
181 ms33364 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; vector<ll> h(n); vector<pair<ll, ll>> hsort(n); vector<bool> present(n, true); for (ll i = 0; i < n; ++i) { cin >> h[i]; hsort[i].first = h[i]; hsort[i].second = i; } sort(hsort.begin(), hsort.end()); if (n == 1) { cout << "1\n"; return 0; } ll ans = 1, isl = 1; for (ll i = 0; i < n; ++i) { if (i != 0 && hsort[i].first != hsort[i - 1].first) { ans = max(ans, isl); } ll idx = hsort[i].second; present[idx] = false; if (idx == 0) { isl -= !present[1]; continue; } if (idx == n - 1) { isl -= !present[n - 2]; continue; } if (!present[idx - 1] && !present[idx + 1]) { isl--; continue; } if (present[idx - 1] && present[idx + 1]) { isl++; continue; } } ans = max(ans, isl); cout << ans << "\n"; }
#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...