제출 #1263130

#제출 시각아이디문제언어결과실행 시간메모리
1263130sohamsen15지구 온난화 (NOI13_gw)C++20
6 / 40
78 ms4168 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);

    int n, lo = 0, hi = 999, best = 0; cin >> n;
    vector<int> a(n); for (auto &x: a) cin >> x;
    function<int(int)> f = [&](int h) {
        bool curr = false; int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > h) {
                if (!curr) ans++, curr = true;
            } else curr = false;
        }
        return ans;
    };
    
    while (hi - lo > 3) {
        int m1 = lo + (hi - lo) / 3;
        int m2 = hi - (hi - lo) / 3;
        if (f(m1) < f(m2)) lo = m1 + 1;
        else hi = m2 - 1;
    }

    for (int 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...