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

34439번 - Darts for Programmers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB32131244.444%

문제

After a long day of programming challenges, you decide to relax with your friends by playing darts. The only problem is that none of your friends (nor the author) have any clue how scoring works! Rather than try to learn, you simply devise your own rules. The rules you come up with are as follows:

  • Each player throws 3ドル$ darts at the board on their turn.
  • The score for that player's turn is the largest sum of the wedge numbers around the dart board between two circularly adjacent darts, including the wedges the darts land in.
  • If two darts land in the same wedge, $x,ドル the sum around the dartboard from $x$ to $x$ is $x$.
  • If all three darts land in the same wedge, the score for that turn is the number of the wedge they all land in.
  • Nobody is accurate enough to hit the bullseye, so we can safely ignore it.

For example, if your darts land in wedges 1ドル,ドル 10ドル,ドル and 7ドル$ on your turn, you would calculate the sum around the dart board from wedge 1ドル$ through wedge 10ドル$ (1ドル + 18 +たす 4 +たす 13 +たす 6 +たす 10 = 52$), the sum around the dart board from wedge 10ドル$ through wedge 7ドル$ (10ドル + 15 +たす 2 +たす 17 +たす 3 +たす 19 +たす 7 = 73$) and the sum around the dart board from wedge 7ドル$ through wedge 1ドル$ (7ドル + 16 +たす 8 +たす 11 +たす 14 +たす 9 +たす 12 +たす 5 +たす 20 +たす 1 = 103$). The sum around the dart board from wedge 7ドル$ through wedge 1ドル$ is the largest sum, so your score would be 103ドル$ points.

The order of the wedges on the dartboard, starting from the top and going clockwise, is 20ドル,ドル 1ドル,ドル 18ドル,ドル 4ドル,ドル 13ドル,ドル 6ドル,ドル 10ドル,ドル 15ドル,ドル 2ドル,ドル 17ドル,ドル 3ドル,ドル 19ドル,ドル 7ドル,ドル 16ドル,ドル 8ドル,ドル 11ドル,ドル 14ドル,ドル 9ドル,ドル 12ドル,ドル 5ドル$.

입력

The first line contains a single integer $N,ドル representing the number of players.

The subsequent $N$ lines each contain three (3ドル$) space-separated integers $w_1,ドル $w_2,ドル and $w_3$ (in that order). Each $w_i$ represents the wedge number that the $i^\text{th}$ dart for that player landed in.

출력

The output should contain $N$ lines. Each line should contain the score for the corresponding player, in the same order in which they appear in the input.

제한

  • 0ドル < N \leq 100\ 000$.
  • All $w_i$ is guaranteed to be between 1ドル$ and 20ドル,ドル inclusive.

예제 입력 1

3
1 4 8
5 17 11
9 9 2

예제 출력 1

120
111
115

노트

출처

School > CS@Mines > CS@Mines HSPC 2019 D번

  • 문제를 만든 사람: Sumner Evans
(追記) (追記ここまで)

출처

대학교 대회

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

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