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

F. Machine Works

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

의견: 0

설명

You are the director of Arbitrarily Complex Machines (ACM for short), a company producing advanced machinery using even more advanced machinery. The old production machinery has broken down, so you need to buy new production machines for the company. Your goal is to make as much money as possible during the restructuring period. During this period you will be able to buy and sell machines and operate them for profit while ACM owns them. Due to space restrictions, ACM can own at most one machine at a time. During the restructuring period, there will be several machines for sale. Being an expert in the advanced machines market, you already know the price \(Pi\) and the availability day \(Di\) for each machines \(Mi\). Note that if you do not buy machine \(Mi\) on day \(Di\), then somebody else will buy it and it will not be available later. Needless to say, you cannot buy a machine if ACM has less money than the price of the machine. If you buy a machine \(Mi\) on day \(Di\), then ACM can operate it starting on day \(Di + 1\). Each day that the machine operates, it produces a profit of \(Gi\) dollars for the company. You may decide to sell a machine to reclaim a part of its purchase price any day after you’ve bought it. Each machine has a resale price \(Ri\) for which it may be resold to the market. You cannot operate a machine on the day that you sell it, but you may sell a machine and use the proceeds to buy a new machine on the same day. Once the restructuring period ends, ACM will sell any machine that it still owns. Your task is to maximize the amount of money that ACM makes during the restructuring.

제약
입력 형식

The input consists of several test cases. Each test case starts with a line containing three positive integers \(N\), \(C\), and \(D\). \(N\) is the number of machines for sale (\(N \le 10^{5}\)), \(C\) is the number of dollars with which the company begins the restructuring (\(C \le 10^{9}\)), and \(D\) is the number of days that the restructuring lasts (\(D \le 10^{9}\)). Each of the next \(N\) lines describes a single machine for sale. Each line contains four integers \(D_{i}\), \(P_{i}\), \(R_{i}\) and \(G_{i}\), denoting (respectively) the day on which the machine is for sale, the dollar price for which it may be bought, the dollar price for which it may be resold and the daily profit generated by operating the machine. These numbers satisfy \(1 \le Di \le D\), \(1 \le Ri < Pi \le 10^{9}\) and \(1 \le Gi \le 10^{9}\). The last test case is followed by a line containing three zeros.

출력 형식

For each test case, display its case number followed by the largest number of dollars that ACM can have at the end of day \(D + 1\). Follow the format of the sample output.

예제 1
입력
6 10 20
6 12 1 3
1 9 1 2
3 2 1 2
8 20 5 4
4 11 7 4
2 10 9 1
0 0 0
ICPC 2011 World Finals Problem F: Machine Works
출력
Case 1: 44
문제 정보

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

출처 ICPC World Finals 2011

평가 및 의견

F. Machine Works

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

Log in to rate problems.

개별 의견

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

풀이 제출

F. Machine Works

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