Editorial for Dãy Mớ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.

Ta giải quyết bài toán bằng cách duyệt qua dãy \(a\), lưu giá trị lớn nhất của \(a_i\) đã duyệt qua trong biến \(max\), sau đó tính giá trị \(ans_k\) bằng tích của giá trị lớn nhất \(max\) đã lưu và \(b_k\). Giá trị \(ans_k\) chính là phần tử \(c_k\) của dãy \(c\). Tại mỗi vòng lặp, ta sẽ in ra giá trị \(ans_k\) tương ứng với phần tử \(c_k\) của dãy \(c\).

Độ phức tạp của thuật toán là \(O(n)\), với \(n\) là số phần tử của mỗi dãy \(a\)\(b\).



Comments

There are no comments at the moment.