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

29901번 - Monkeying Around 다국어

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

문제

$N$ baby monkeys are playing in treetops. They all start from the same height, and each of them finishes where it started from. Each monkey makes $M$ jumps, denoted by integers that show how many centimeters higher or lower the monkey moved with that jump. For each monkey, the height of one of the jumps in unknown and represented as zero in the input data. Find the monkey who was on the highest level on average (assuming the jumps take place after equal time intervals).

입력

The first line contains $N$ (1ドル \le N \le 100$), the number of monkeys, and $M$ (1ドル \le M \le 100$), the number of jumps. Each of the following $N$ lines contains $M$ space-separated integers $A_i$ ($-200 \le A_i \le 200$) showing how many centimeters higher the corresponding monkey moved with the corresponding jump (negative values indicate moving lower). There is exactly one 0ドル$ on each line, indicating that we do not know how much higher or lower the monkey moved with that jump.

출력

Output exactly one integer, the index of the monkey who was on the highest level on average. The monkeys are indexed 1,ドル \ldots, N$ in the order in which their data are given in the input. When computing the average, the common final height after the last jump is included, but the initial height before the first jump is excluded. If there are several monkeys with the maximal average level, output the index of any of them.

제한

예제 입력 1

2 2
1 0
0 3

예제 출력 1

1

Two monkeys, each jumped twice. The first jump of the first monkey was 1ドル$cm up. For the monkey to return to the initial position, the second jump must have been 1ドル$cm down. The average height measured relative to the starting point was $(1 + 0) / 2 = 0.5$.

The first jump of the second monkey must have been 3ドル$ cm down for it to return to the initial position with the second jump. The average height was $(-3 + 0) / 2 = -1.5$.

So, the average height of the monkey number 1ドル$ was 0ドル.5$ and the average height of the monkey number 2ドル$ was $-1.5$. Thus, on the average, the monkey number 1ドル$ was on the highest level.

예제 입력 2

3 4
-2 4 0 6
-3 0 -8 9
4 5 -7 0

예제 출력 2

3

The "unknown" jumps of the monkeys are $-8,ドル 2ドル,ドル and $-2$cm, respectively.

Their heights after each jump:

$-2,ドル 2ドル,ドル $-6,ドル 0ドル$;

$-3,ドル $-1,ドル $-9,ドル 0ドル$;

4ドル,ドル 9ドル,ドル 2ドル,ドル 0ドル$.

Their average heights:

$(-2 + 2 + (-6) + 0) / 4 = -1.5$;

$(-3 + (-1) + (-9) + 0) / 4 = -3.25$;

$(4 + 9 + 2 + 0) / 4 = 3.75$.

힌트

출처

Olympiad > Estonian Informatics Olympiad > 2020-21 > Final Round 2번

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

출처

대학교 대회

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

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