RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0396 파일 입출력

Greedy Pie Eaters

Diamond IV 다이아몬드 IV
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John has \(M\) cows, conveniently labeled \(1 \ldots M\), who enjoy the occasional change of pace
from eating grass. As a treat for the cows, Farmer John has baked \(N\) pies (\(1 \leq N \leq 300\)), labeled
\(1 \ldots N\). Cow \(i\) enjoys pies with labels in the range \([l_i, r_i]\) (from \(l_i\) to \(r_i\) inclusive),
and no two cows enjoy the exact same range of pies. Cow \(i\) also has a weight, \(w_i\), which
is an integer in the range \(1 \ldots 10^6\).

Farmer John may choose a sequence of cows \(c_1,c_2,\ldots, c_K,\) after which the
selected cows will take turns eating in that order. Unfortunately, the cows
don't know how to share! When it is cow \(c_i\)'s turn to eat, she will consume
all of the pies that she enjoys --- that is, all remaining pies in the interval
\([l_{c_i},r_{c_i}]\). Farmer John would like to avoid the awkward situation
occurring when it is a cows turn to eat but all of the pies she enjoys have already been
consumed. Therefore, he wants you to compute the largest possible total weight
(\(w_{c_1}+w_{c_2}+\ldots+w_{c_K}\)) of a sequence \(c_1,c_2,\ldots, c_K\) for which each cow in the
sequence eats at least one pie.

Problem credits: Benjamin Qi

제약

SCORING

  • Test cases 2-5 satisfy \(N\le 50\) and \(M\le 20\).
  • Test cases 6-9 satisfy \(N\le 50.\)

Problem credits: Benjamin Qi

입력 형식

The first line contains two integers \(N\) and \(M\)
\(\left(1\le M\le \frac{N(N+1)}{2}\right)\).

The next \(M\) lines each describe a cow in terms of the integers \(w_i, l_i\), and \(r_i\).

출력 형식

Print the maximum possible total weight of a valid sequence.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 pieaters.in
출력을 쓸 파일 pieaters.out
예제 1
입력
2 2
100 1 2
100 1 1
출력
200
설명

In this example, if cow 1 eats first, then there will be nothing left for cow 2 to eat. However,
if cow 2 eats first, then cow 1 will be satisfied by eating the second pie only.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2019-2020 > December > Platinum

태그

평가 및 의견

Greedy Pie Eaters

개요
출제자 난이도 Diamond IV 다이아몬드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Greedy Pie Eaters

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