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

14409번 - Tuna 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB31228225291.304%

문제

Fisherman Šime caught N tunas last night. With the help of a special app, he offerred them for sale to a famous Japanese company that specializes in purchasing quality fish. In what way does the app estimate the value, or the price, of a tuna?

Based on the photo of the tuna, the app returns two estimated values, P1 and P2 . If the difference between the estimates is less than or equal to X, then the higher value is taken. If the difference is strictly larger than X, the app returns a third estimate P3 and then that estimate is taken as the final value of the tuna.

Write a programme that will, based on the given estimates (sometimes two, sometimes three of them) for each of N tunas, output the total value of caught tunas.

입력

The first line of input contains the integer N (1 ≤ N ≤ 20), the number of tunas from the task.

The second line of input contains the integer X (1 ≤ X ≤ 10), the number from the task.

Then, N blocks follow in one of the two following forms:

  • In one line, two integers P1 and P2 (1 ≤ P1 , P2 ≤ 100) from the task, or
  • In one line, two integers P1 and P2 (1 ≤ P1 , P2 ≤ 100) from the task, and in the second line integer P3 (1 ≤ P3 ≤ 100) from the task.

출력

The first and only line of output must contain the total value of caught tunas.

제한

예제 입력 1

5
2
3 4
2 1
5 3
4 4
4 2

예제 출력 1

19

예제 입력 2

4
2
3 5
2 8
4
6 5
6 3
7

예제 출력 2

22

예제 입력 3

3
10
20 50
30
20 40
50
70 20
10

예제 출력 3

90

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2016/2017 > Contest #5 1번

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

출처

대학교 대회

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

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