제출 #1263133

#제출 시각아이디문제언어결과실행 시간메모리
1263133sohamsen15Global Warming (NOI13_gw)C++20
6 / 40
484 ms8260 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ll n, lo = 0, hi = 2e18, best = 0; cin >> n; vector<ll> a(n); for (auto &x: a) cin >> x; function<ll(ll)> f = [&](ll h) { bool curr = false; ll ans = 0; for (ll i = 0; i < n; i++) { if (a[i] > h) { if (!curr) ans++, curr = true; } else curr = false; } return ans; }; while (hi - lo > 3) { ll m1 = lo + (hi - lo) / 3; ll m2 = hi - (hi - lo) / 3; if (f(m1) < f(m2)) lo = m1 + 1; else hi = m2 - 1; } for (ll h = lo; h <= hi; h++) best = max(best, f(h)); cout << best << "\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...