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

Farmer

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

의견: 0

설명

Athens

Version 1.1
Greece

farmer
farmer

Farmer

PROBLEM

A farmer has a set of fields, each of which is surrounded by cypress trees. Also, the farmer
has a set of strips of land, each of which has a row of cypress trees. In both fields and strips,
between every two consecutive cypress trees is a single olive tree. All of the farmer’s
cypress trees either surround a field or are in a strip and all of the farmer’s olive trees are
between two consecutive cypress trees in a field or in a strip.

One day the farmer became very ill and he felt that he was going to die. A few days before
he passed away he called his eldest son and told him, “I give you any Q cypress trees of
your choice and all the olive trees which are between any two consecutive cypress trees you
have chosen.” >From each field and from each strip the son can pick any combination of
cypress trees. Since the eldest son loves olives he wants to pick the Q cypress trees which
will allow him to inherit as many olive trees as possible.

Figure 1. An example setting of cypress trees; olive trees are not shown.

In Figure 1, assume that the son is given Q=17 cypress trees. To maximize his olive
inheritance he should choose all the cypress trees in Field 1 and Field 2, inheriting 17 olive
trees.

You are to write a program which, given the information about the fields and the strips and
the number of cypress trees the son can pick, determines the largest possible number of
olive trees the son may inherit.

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, 0≤Q≤150000, 0≤M≤2000, 0≤K≤2000, 3≤ N1≤150, 3≤N2≤150,... 3≤NM≤150,
2≤ R1≤150, 2≤R2≤150,... 2≤RK ≤150. The total number of cypress trees in the fields and
strips is at least Q. Additionally, in 50% of the inputs, Q≤1500.
17 3 3
13 4 8
4 8 6
17

입력 형식

The input file name is farmer.in. The first line contains first the integer Q: the number
Field 1 has 13 cypress trees
Field 3 has 8 cypress trees
Field 2 has 4 cypress trees
Strip 1 has 4 cypress trees
Strip 2 has 8 cypress trees
Strip 3 has 6 cypress trees

Athens

Version 1.1
Greece

farmer
farmer
of cypress trees the son is to select; then the integer M, the number of fields; and then the
integer K, the number of strips. The second line contains M integers N1, N2,... NM, : the
numbers of cypress trees in fields. The third line contains K integers R1, R2,... RK: the
numbers of cypress trees in strips.

출력 형식

The output file name is farmer.out. The file is to contain one line with one integer: the
largest possible number of olive trees the son may inherit.

EXAMPLE INPUTS AND OUTPUTS

farmer.in

farmer.out

문제 정보

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

출처 IOI 2004

평가 및 의견

Farmer

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

Log in to rate problems.

개별 의견

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

풀이 제출

Farmer

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