Editorial for Số Chẵn Lớn Nhất


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.

Subtask 1

Làm theo yêu cầu đề bài với độ phức tạp \(O(N^2)\).

Subtask 2

Ta nhận ra rằng tổng của số chẵn là tổng của hai số lẻ hoặc hai số chẵn. Vì vậy ta sẽ tách dãy thành hai dãy số chẵn và số lẻ. Ta sẽ cộng lại hai phần tử lớn nhất của hai dãy đã tách và in ra giá trị lớn hơn giữa hai dãy đó. Độ phức tạp là \(O(NLogN)\).



Comments

There are no comments at the moment.