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

6838번 - Candy 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB6911915.789%

문제

You and a friend have a big bag of candy. You want to keep slim and trim, and so you would like to equalize the candy which you are sharing with your friend in terms of calorie count. That is, your task is to divide the candies into two groups such that the number of calories in each group is as close together as possible.

입력

The first line of input contains the number of different kinds of candy you have in your bag of candy N (1 ≤ N ≤ 100). On the following N lines, there are pairs of numbers describing each type of candy. The candy description is of the form ki ci where ki is the number of that particular type of candy contained in the bag and ci is the calorie count for each piece of that type of candy. You may assume that 1 ≤ ki ≤ 500 and 1 ≤ ci ≤ 200.

출력

Your output is one integer which is the minimum difference of calories between friends

제한

예제 입력 1

4
3 5
3 3
1 2
3 100

예제 출력 1

74

힌트

Your friend takes two of the 100-calorie candies, for a total of 200 calories. You keep the remaining candies, which have 126 calories.

출처

Olympiad > Canadian Computing Competition & Olympiad > 2008 > CCO 2008 5번

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

출처

대학교 대회

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

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