[USACO12MAR] 정원 녹화 Landscaping
2567 단어 DP
제목 설명
Farmer John is building a nicely-landscaped garden, and needs to move a large amount of dirt in the process.
The garden consists of a sequence of N flowerbeds (1 <= N <= 100), where flowerbed i initially contains A_i units of dirt. Farmer John would like to re-landscape the garden so that each flowerbed i instead contains B_i units of dirt. The A_i's and B_i's are all integers in the range 0..10.
To landscape the garden, Farmer John has several options: he can purchase one unit of dirt and place it in a flowerbed of his choice for X.HecanremoveoneunitofdirtfromaflowerbedofhischoiceandhaveitshippedawayforX.HecanremoveoneunitofdirtfromaflowerbedofhischoiceandhaveitshippedawayforY. He can also transport one unit of dirt from flowerbed i to flowerbed j at a cost of $Z times |i-j|. Please compute the minimum total cost for Farmer John to complete his landscaping project.
입력
* Line 1: Space-separated integers N, X, Y, and Z (0 <= X, Y, Z <= 1000).* Lines 2..1+N: Line i+1 contains the space-separated integers A_i and B_i.
출력
* Line 1: A single integer giving the minimum cost for Farmer John's landscaping project.
샘플 입력
4 100 200 11 42 33 24 0
샘플 출력
210
문제풀이: 이 문제는 데이터가 비교적 작기 때문에 데이터를 벌려 처리할 수 있다.그 다음에 동태적인 기획으로 해결한다.
#include
#include
int n,x,y,z,la,lb,a[1005],b[1005],f[1005][1005];
using namespace std;
inline int minn(int x,int y)
{
return x
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[BOJ]11048(python)python 풀이 DP를 이용해 풀이 보통 이런 문제는 dfs나 bfs로 풀이하는 것이여서 고민을 했는데 이 문구 덕분에 DP 를 이용해 풀이할 수 있었다 뒤로 돌아가는 등의 경우를 고려하지 않아도 되기 때문이다 코...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.