RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00284

Kolinje

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(3^{rd}\) round, December \(7^{th}\), 2013

Melita has just returned from the annual pig slaughter. Don't worry, this is a regular thing in Croatia.
The best part was the abundance of food! There was everything, starting from good spicy sausages,
ham, black pudding, up to teewurst, top quality bacon and čvarci, all with warm white bread and butter.
After these appetizers, it was the perfect time to whip up a deep pot full of sarma (Melita ate twentyish
of them) as well as a large platter of fine roast pork, so soft that it almost melts in your mouth. They
watered all of this down with copious gulps of the best dry white wine that made them even hungrier.
Butcher Bajs kept his awa\(rd-wi\)nning ham for the very end. N people attented the annual pig slaughter,
labeled with numbers from 1 to N. These people already ate a lot of meat: the k^{th} person ate A[k]
kilograms of meat so far. Bajs will distribute his ham to the people in the ratio B[1] : B[2] : ... : B[N],
exactly in that order, but he doesn't know the total amount (number of kilos) of ham which he will be
distributing yet.
At the end of the slaughter, the Man of the Year will be declared. A ranking list is made according to
the total kilos of meat eaten. Bajs impacts directly on this list by choosing the amount of ham to
distribute. Although Bajs has been offered bribes many times, he refused each time, saying that he was
an honest man who would not hurt a fly.
Bajs cares about order, because he's a nice gentleman, and wants to have the order of people in the
exact form of 1, 2, 3, ..., N, respectively from the one who ate the most kilos of meat to those who ate
less, allowing ties between participants. Help Bajs select the total amount of ham that he will distribute
(in the ratio mentioned before) to achieve his intention.

제약
입력 형식

The first line of input contains an integer N (\(2 \le N \le 1000\)), the number of competitors for the Man
of the Year award.
Each of the following k lines contains integers A[k] i B[k], as mentioned in the text (\(0 \le A\)[k], B[k] ≤
\(10^{6}\)). At least one of the numbers B[k] will not be equal to 0.

출력 형식

The first and only line of output must conta\(in -1\) if the required order cannot be achieved. Otherwise,
output the required amount of ham in kilos, a real number (rounded up to 12 decimal places) between
0 and \(10^{7}\) (inclusive). If there are multiple possible solutions, output any.

예제 1
입력
3
7 1
3 2
10 0
출력
10.5
예제 2
입력
3
2 1
4 0
0 3
출력
-1
예제 3
입력
5
15 4
6 7
12 5
9 6
1 7
출력
87
설명

Clarification of the first example: 10.5 kilos of ham is distributed in the ratio 1 : 2 : 0, which gives us
3.5, 7 and 0 kilos of ham, respectively. If we add this to the already eaten amount of meat, we conclude
that the participants ate 10.5, 10 and 10 kilos in total, which is a valid order.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2013/2014 Contest 3

평가 및 의견

Kolinje

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Kolinje

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8