• Keine Ergebnisse gefunden

The laws prescribe that the distance between two wind turbines has to be at leastD meters

N/A
N/A
Protected

Academic year: 2022

Aktie "The laws prescribe that the distance between two wind turbines has to be at leastD meters"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Student ID: Algorithmen & Datenstrukturen page 1

Programming Task P1. / 20 P

Enrollment Key: testitwell

Submission Link:

https://judge.inf.ethz.ch/team/websubmit.php?cid=28776&problem=WindT18

Wind Turbines

We want to place wind turbines along one road out of our town to produce energy. Due to the local conditions, n different positions are possible, some better suited than others. The laws prescribe that the distance between two wind turbines has to be at leastD meters.

The npossible positions are given as the distances d1, . . . , dn in meters from the start of the road, e.g. as coordinates on a line, such that 0≤di < di+1 for alli∈ {1, . . . , n−1}. When a wind turbine is installed at location iit produces energyei, where all the values ofe1, . . . , en are also given.

The task is to determine where to build the wind turbines to maximizes the total energy yield (the sum of energy produced). The number of turbines to build is limited only by the numbernand the minimal distance constraint.

Example

The image above shows a situation for n= 5 possible positions. For example, if a wind turbine is installed at position 3, no wind turbines can be installed at the positions 2 or 4. When the wind turbines are placed on the positions 1, 3 and 5, they produce 6 + 5 + 11 = 22 units of energy.

This solution is not optimal: An installation of wind turbines on the positions 2 and 4 produces 9 + 15 = 24 units of energy.

Grading You can get up to 20 judge points. To get full points your program should requireO(n) time (with reasonable hidden constants). Less efficient solutions can obtain up to 5 points.

Instructions

For this exercise, we provide a program template as an Eclipse project in your workspace that helps you reading the input and writing the output. Importing any additional Java class is not allowed (with the exception of the already imported ones java.io.{InputStream, OutputStream}

and java.util.Scannerclass). Submit only your Main.java.

The project also contains data for your local testing and aJUnitprogram that runs yourMain.java on all the local tests – just open and run WindTurbinesTest.launchin the project. The local test data are different and generally smaller than the data that are used in the online judge.

(2)

Student ID: Algorithmen & Datenstrukturen page 2

The input and output are handled by the template – you should not need the rest of this text.

Input The input of this problem consists of a number of test-cases.

Each case is independent of the others and consists of three lines: The first line contains the integers n >0 and D >0 separated by a space. The second line contains nintegers d1 to dn separated by spaces. The third line contains nintegerse1 toen separated by spaces.

Output For every case, the output should contain one integer number on a separate line – the maximal total energy yield of that case.

The output contains one line for each test-case. More precisely, thei-th line of the output contains a single integer corresponding to the the maximum total energy yield of thei-th test-case.

Example input (as in the figure above plus one more case).

2 5 5

0 4 6 10 13 6 9 5 15 11 5 1

1 2 3 5 6 3 2 4 5 1

Example output:

24 15

Referenzen

ÄHNLICHE DOKUMENTE

Specific focus is given to the role of article 27 of the Trade Related Intellectual Property Rights (TRIPS) agreement as well as the Convention of Biological Diversity (CBD)

To assess the usefulness of incorporating structural breaks in the predictive relation of the yield curve and output growth, a recursive out-of-sample forecasting exercise is

Both theoretically and empirically the output gap is an important variable used in contemporary macroeconomic models of inflations. Theoretically, the link between output gap

C The fiscal policy could affect the flows of incomes and expenditures, the global level of social output as well as the “monetary balances” via the changes in the

Using the GETS approach, the test is executed on variables like export ratio, ratio of aid to GDP and remittance ratio (ratio of remittance to employment) to examine whether they

This study is aimed to analyze the tourism contributions to the Brazilian economy by using a tourism input-output matrix constructed for the Brazilian economy

While P t f in and C t are the same in both model versions, the aggregate markup ξ t is higher in the steady state of the European VAT model, because retail firms use it to roll

Furthermore we obtain a positive solution of the Membership Problem for finitely generated quadratic modules not just in R [X 1 ] but in R[X 1 ] where R is an arbitrary real