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

28679번 - Candy 서브태스크다국어

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

문제

In the ancient city of Ica, there is said to be a palace with wealth beyond imagination. Inside, there is a corridor with $N$ boxes of candy from all over the world. Travellers passing by can take as much candy as they want, provided that they pay its weight in gold.

The boxes of candy are numbered 0ドル$ to $N-1$ from left to right. In box $i,ドル there are $a_i$ units of candy left, where $a_i$ is a non-negative integer.

As the guardian of the palace, you would like to move the boxes around so that boxes with a lot of candy end up closer to the entrance.

You are given the array $a_0, a_1, \ldots, a_{N-1},ドル as well as the numbers $F$ and $T$. In a single operation, you are allowed to swap two adjacent elements of $a_0, a_1, \ldots, a_{N-1}$. What is the minimum number of operations required so that the first $F$ elements of the array sum to at least $T$?

입력

The first line of the input contains three integers, $N,ドル $F,ドル and $T$.

The second line of the input contains $N$ integers $a_0, a_1, \ldots, a_{N-1}$.

출력

If it is impossible to achieve the objective using the operations, print NO.

Otherwise, print a single integer, the minimal number of operations.

제한

  • 1ドル \le N \le 100$.
  • 1ドル \le F \le N$.
  • 0ドル \le T \le 10^{11}$.
  • 0ドル \le a_i \le 10^9$ for $i = 0, 1, \ldots, N-1$.

The numbers in the input may not fit in a 32ドル$-bit integer, so be aware of overflows if you are using C++.

서브태스크

번호배점제한
16

$N \le 2$ and $a_i \le 100$ for $i = 0, 1, \ldots, N-1$ and $T \le 10^9$

219

$a_i \le 1$ for $i = 0, 1, \ldots, N-1$

316

$N \le 20$

430

$a_i \le 100$ for $i = 0, 1, \ldots, N-1$

529

No additional constraints

예제 입력 1

6 2 27
10 4 20 6 3 3

예제 출력 1

1

예제 입력 2

6 5 5000000000
1000000000 1000000000 0 1000000000 1000000000 1000000000

예제 출력 2

3

예제 입력 3

3 2 100
20 30 60

예제 출력 3

NO

예제 입력 4

1 1 100
100

예제 출력 4

0

힌트

In the first sample test case, the first two elements should sum to at least 27ドル$. This can be achieved by a single swap of two adjacent elements: swap the 4ドル$ and 20ドル$. After this swap, the array becomes 10 20 4 6 3 3, and indeed the first two elements sum to 10ドル+20 = 30\ge 27$.

In the second sample test case, the 0ドル$ must move all the way to the end of the array; this takes three swaps.

In the third sample test case, it is impossible to make the first two elements sum to at least 100ドル$; the best we can do is 60ドル+30=90$.

출처

Olympiad > European Girls' Olympiad in Informatics > EGOI 2023 > Day 2 B번

  • 문제를 만든 사람: Yann Viegas

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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