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

Phidias

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

의견: 0

설명

Athens

Version 1.1
Greece

phidias
phidias

Phidias

PROBLEM

Famous ancient Greek sculptor Phidias is making preparations to build another marvelous
monument. For this purpose he needs rectangular marble plates of sizes W1 × H1, W2 ×
H2, ..., WN × HN.

Recently, Phidias has received a large rectangular marble slab. He wants to cut the slab to
obtain plates of the desired sizes. Any piece of marble (the slab or the plates cut from it) can
be cut either horizontally or vertically into two rectangular plates with integral widths and
heights, cutting completely through that piece. This is the only way to cut pieces and pieces
cannot be joined together. Since the marble has a pattern on it, the plates cannot be rotated:
if Phidias cuts a plate of size A × B then it cannot be used as a plate of size B × A unless A =
B. He can make zero or more plates of each desired size. A marble plate is wasted if it is
not of any of the desired sizes after all cuts are completed. Phidias wonders how to cut the
initial slab so that as little of it as possible will be wasted.

As an example, assume that in the figure below the width of the original slab is 21 and the
height of the original slab is 11, and the desired plate sizes are 10 × 4, 6 × 2, 7 × 5, and 15 ×
10. The minimum possible area wasted is 10, and the figure shows one sequence of cuts
with total waste area of size 10.

Your task is to write a program that, given the size of the original slab and the desired plate
sizes, calculates the minimum total area of the original slab that must be wasted.

Note (RiseOJ) — The original statement describes file-based input/output; on this judge your program must read from standard input and write to standard output instead.

제약

In all inputs, 1 ≤ W ≤ 600, 1 ≤ H ≤ 600, 0 < N ≤ 200, 1 ≤ Wi ≤ W, and 1 ≤ Hi ≤ H.
Additionally, in 50% of the inputs, W ≤ 20, H ≤ 20 and N ≤ 5.

21 11
4
10 4
6 2
7 5
15 10
10

입력 형식

The input file name is phidias.in. The first line of input contains two integers: first W,
the width of the original slab, and then H, the height of the original slab. The second line
contains one integer N: the number of desired plate sizes. The following N lines contain the
desired plate sizes. Each of these lines contains two integers: first the width Wi and then the
height Hi of that desired plate size (1 ≤ i ≤ N).

출력 형식

The output file name is phidias.out. The file is to contain one line with a single integer:
the minimum total area of the original slab that must be wasted.

10 4
10 4
6 2
6 2
6 2
7 5
7 5
7 5

Athens

Version 1.1
Greece

phidias
phidias
EXAMPLE INPUTS AND OUTPUTS

phidias.in

phidias.out

문제 정보

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

출처 IOI 2004

평가 및 의견

Phidias

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

Log in to rate problems.

개별 의견

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

풀이 제출

Phidias

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