시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 512 MB21314511465.517%

문제

The Bureau for Artificial Problems in Competitions wants you to solve the following problem: Given \(n\) positive integers \(a_1, \dots , a_n\), what is the maximal value of

\(\left(a_1^2 + \cdots + a_k^2 \right) \cdot \left( a_{k+1} + \cdots + a_n \right)\)?

입력

  • A single line containing an integer 2 ≤ \(n\) ≤ 106.
  • Then follow \(n\) lines, the \(i\)th of which contains the integer 1 ≤ \(a_i\) ≤ 100.

출력

Output the maximal value of the given expression.

예제 입력 1

5
2
1
4
3
5

예제 출력 1

168

예제 입력 2

2
1
1

예제 출력 2

1

예제 입력 3

10
8
5
10
9
1
4
12
6
3
13

예제 출력 3

10530

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2019 Preliminaries I번

  • 문제를 만든 사람: Onno Berrevoets