Editorial for Học sinh ham chơi


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Spoiler Alert


Hint 1

  • Ta chỉ cần tìm \(max_a = max(\forall a_i \in a[])\) của mảng

Chứng minh: \(max_a \geq \frac{max_a * k}{k} \geq \frac{max(a_{i + 1} + a_{i + 2} + ... + a_{i + k}) * k}{k} \geq \frac{a_{i + 1} + a_{i + 2} + ... + a_{i + k}}{k}\)

Reference AC code | O(n) time | O(1) auxiliary space | Online Solving

C++
int main()
{
    int mx = 0;
    for (int n = readInt(); n--; mx = max(mx, readInt()));
    cout << mx;
    return 0;
}


Comments

There are no comments at the moment.