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

Traka

Platinum I 플래티넘 I
난이도
1s
시간 제한
128MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

As mentioned before, there are \(N\) workers in Mirko's factory. They are manufacturing cars on a conveyor belt, in a pipeline fashion. Workers are denoted by numbers \(1\) – leftmost, to \(N\) - rightmost. Each of the workers does his specific job and requires certain amount of time to complete it.

Production of a single car starts with worker #1 (Mirko). After he had finished with his part of the job, worker #2 takes over, after him #3... When worker #N finishes with his part, the car is finished. Mirko and his workers have to produce \(M\) cars and they must produce them in order \(1\) to \(M\).

For every worker \(i\) we know \(T_i\) — time required for him to do his part of the job. For every car \(j\) we know factor of assembly complexity \(F_j\). Time in minutes for worker \(i\) to finish his part of the job on the car \(j\) is computed as a product \(T_i \cdot F_j\).

After some worker has finished working on a car, he has to give it to the next worker instantly, without any delay (weird company policy). For that reason, the worker receiving the car has to be free (he must not be working on some other car). In order to fulfill this condition, Mirko has to choose a good timing to start building a new car. To be efficient, he'll wait minimum number of minutes until he is certain that all of the conditions described are met.

Write a program which will, given worker times and factors of complexity for each car, compute total time required for producing all of the cars.

제약

In test cases worth 40% of total points, N and M will be at most 1000.

입력 형식

First line of input contains space-separated positive integers \(N\) (\(1 \le N \le 100\,000\)), number of workers, and \(M\) (\(1 \le M \le 100\,000\)), number of cars.

\(i\)-th of the following \(N\) lines contains worker time \(T_i\) for the worker \(i\).

\(j\)-th of the following \(M\) lines contains factor of complexity \(F_j\) for the car \(j\).

These conditions hold: \(1 \le T_i \le 10\,000\), \(1 \le F_j \le 10\,000\).

출력 형식

First and only line of output has to contain required number of minutes.

Scoring: In test cases worth \(40\%\) of total points, \(N\) and \(M\) will be at most \(1000\).

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
3 3
2
1
1
2
1
1
출력
11
예제 2
입력
3 3
2
3
3
2
1
2
출력
29
예제 3
입력
4 5
3
2
2
2
3
1
2
1
2
출력
55
문제 정보

riseoj 작성

출처 COCI 2011/2012 Contest 3

평가 및 의견

Traka

개요
출제자 난이도 Platinum I 플래티넘 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Traka

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