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

21132번 - Best Solution Unknown 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB98564656.790%

문제

You are the responsible holder of a competition called Best Solution Unknown (BSU). The rules of this competition are simple but rather quirky.

First, all the $n$ participants stand in a row. Then, $n-1$ matches are held. In each match, jury chooses two adjacent players. The chosen players are given an NP-hard problem, and they try their best to come up with a good solution. The one who provides a better solution wins a round, the other one leaves the competition. After that, players shift to form a valid row again, so the player adjacent to the player that has left the competition becomes adjacent to the winner of the round. As you can see, after all the $n-1$ matches, only one player remains, and this player is declared a winner of the competition.

You know the competitors well, so you know the strength of each player before the competition. The strength of the $i$-th player, counting from the left of the row, is $a_i$. You also know that a player with greater strength wins the match. If the players have equal strength, both have a chance to win. You have noticed that victories motivate the players, so the strength of the winner of a match increases by one.

However, you do not know who plays in each match and who wins a match in case of equal strengths. So, you are wondering who can become the winner of the competition. You thought it was a good problem for the participants of BSU, but, unfortunately, it is not NP-hard, so you have to solve it yourself.

입력

The first line contains an integer $n,ドル denoting the number of participants of BSU (1ドル \le n \le 10^6$).

The second line contains $n$ integers $a_i,ドル where $a_i$ is the initial strength of the $i$-th participant (1ドル \le a_i \le 10^9$).

출력

The first line should contain an integer $k,ドル the number of participants that can possibly win the competition (1ドル \le k \le n$).

The second line should contain $k$ integers $b_i$ in strictly increasing order, the indices of these participants (1ドル \le b_1 < b_2 < \ldots < b_k \le n$).

제한

예제 입력 1

3
3 2 2

예제 출력 1

3
1 2 3

예제 입력 2

3
1 2 1

예제 출력 2

1
2

예제 입력 3

5
1 2 3 5 5

예제 출력 3

3
3 4 5

예제 입력 4

1
10

예제 출력 4

1
1

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud N번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus N번

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

출처

대학교 대회

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

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