프로그램 명: boi_glo(special judge)
제한시간: 1 초
//sj가 아직...
[요약 중]
글러브가 있는 두 서랍이 있다. 하나는 오른손 잡이 , 하나는 외손잡이가 들어 있다.
각각 n 개의 다른 색깔 이다.
교수는 안다. 각 서랍에 어떤 색의 글러브가 어느만큼 있는지.
(같은 색의 글러브의 수는 각 서랍에서 서로 다르다)
그는 또한 확실하다 같은 색의 글러브의 짝을 찾는 것이 가능하다.
교수의 실험은 성공 한다. 같은 색의 글러브를 사용해야지만 ( 어든 것인지는 중요하지 않다)
그래서 모든 실험 전에 그는 베이스먼트로 가서
적어도 같은 색의 짝을 가지는 것을 희망하면서 .
베이스먼트가 너무 어두워 밖으로 나가지 않고 글러브의 색을 인식하는 것은
교수는 싫어한다. 지하로 내려가는 것을 한번 이상 (
as well as bringing unnecessarily large amounts of gloves to the laboratory.
In the dark basement of chemistry professor Acidrain’s house there are two
drawers with gloves - one with left hand and other with right hand gloves.
In each of them there are gloves of n difierent colours. Professor knows how
many gloves of each colour there are in each drawer (the number of gloves of
the same colour may difier in both drawers). He is also sure that it is possible
to find a pair of gloves of the same colour.
Professor’s experiment may be successful only if he uses gloves of the same
colour (it does not matter which one), so before every experiment he goes to
the basement and takes gloves from the drawers hoping that there will be at
least one pair of the same colour. It is so dark in the basement that there is no
possibility to recognize colour of any glove without going out of the basement.
Professor hates going to the basement more than once (in case there was no
pair of gloves of the same colour), as well as bringing unnecessarily large
amounts of gloves to the laboratory.
Task
Write a program that:
-
reads the number of colours and the number of gloves in each colour in
each drawer from the standard input,
-
calculates the smallest total number of gloves which must be taken to be
sure that among them it is possible to find at least one pair of gloves of
the same colour (it is necessary to specify the exact number of gloves to
be taken from each drawer),
-
writes the result to the standard output.
입력
-
The first line of the standard input contains one positive integer n (1 <= n <= 20 )
describing the number of distinct colours. The colours are numbered from 1 to n.
-
The second line of input contains n non-negative integers Gloves 0 <= a1, a2,... an <= 10^8 , where ai corresponds to the number of gloves of colour
number i in the drawer with left hand gloves.
- Finally, the third line of input contains n non-negative integers 0 <= b1, b2,..., bn <= 10^8 , where bi corresponds to the number of gloves of colour number i in the drawer with right hand gloves.
Additionally, in test cases worth 40% of points, n <= 4 and ai,bi <= 10 .
출력
-
The first line of the standard output should contain a single integer - the
number of gloves which must be taken from the drawer with left hand gloves.
-
The second line of output should contain a single integer - the number of
gloves which must be taken from the drawer with right hand gloves. The sum
of these two numbers should be as small as possible.
If there are several correct results, your program should output any of them.
입출력 예
입력
4
0 7 1 6
1 5 0 6
출력
2
8
출처:BOI 2008 5/7
[질/답]
[제출 현황]
[푼 후(0)]