Logo
(追記) (追記ここまで)

27187번 - Lazy to Win 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB16121275.000%

문제

Alexey is probably the smartest and at the same time the laziest person in the world. Today he is participating in the Olympiad.

At the Olympiad, participants are given $n$ problems. The participant will receive $a_i$ points for the correct solution of the $i$-th problem. No points are given for an incorrect solution. The winner's diplomas will be awarded to those participants who receive at least half of the total number of points. For example, if there are given three problems at the Olympiad, the cost of which in points are 1ドル,ドル 3ドル$ and 4ドル,ドル it is enough to receive four points to be awarded the winner's diploma.

Alexey came to the Olympiad to get a winner's diploma. Alexey is very smart and can correctly solve any problem at the Olympiad. But Alexey is also very lazy and wants to solve as few problems as possible.

Alexey is so lazy that he even lazily chooses tasks that he will solve. He wants to choose some problem with the number $k,ドル and then solve problems with the numbers $k, k+1, k+2 \ldots$ until he has enough points to get a winner's diploma. The maximum that Alexey is ready for is to skip one problem and not solve it, in order to solve even fewer problems in the end.

Determine the minimum number of problems that Alexey needs to solve using his strategy to get the winner's diploma.

입력

On the first line there is one integer $n$ --- the number of problems that were given at the Olympiad (1ドル \le n \le 10^5$).

On the second line there are $n$ integers $a_1, a_2, \dots a_n$ --- the cost of each problem in points (1ドル \le a_i \le 10^9$).

출력

On the first line output single integer --- the minimum number of problems that Alexey needs to solve using his strategy to get the winner's diploma.

제한

예제 입력 1

5
1 1 2 1 2

예제 출력 1

2

예제 입력 2

3
2 3 1

예제 출력 2

1

노트

In the first example, participants need receive at least four points to get the winner's diploma. Alexey can start solving the third problem, then skip the fourth problem and get four points by solving two tasks.

In the second example, it is enough to solve only the second problem and receive three points.

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2022 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /