ECOO '18 R2 P1 - Artificial Photosynthesystem

View as PDF

Points: 7 (partial)
Time limit: 13.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

The technology world is currently working on a way to generate oxygen so that we can combat the effects of climate change. One of the ways that this is being done is through the creation of an artificial photosynthesystem.

the basic idea behind the process is that you need an artificial "leaf" and an artificial "fish" submerged into a vat of carbonated sugar water, which consists of sugar (), water (), oxygen (), and carbon dioxide (). The leaf is capable of photosynthesis, meaning it consumes some amount of carbon dioxide and water and produces sugar and oxygen. Likewise, the fish is capable of respiration, meaning that it consumes sugar and oxygen to produce carbon dioxide and water.

The plan is to create as much oxygen as possible in order to release it into the environment. There have been different experiments completed on the use of this technique, and each of the leaves and fish that were used have generated a different set of data.

Given the following input experimentation data, you are tasked with calculating the largest amount of oxygen that can be generated with this simple artificial photosynthesystem. Someone has already crunched through the data for you, and has calculated the approximate ratios of input versus outputs.

Input Specification

The standard input will contain 10 datasets. Each data set consists of three lines.

• The first line contains four integers , , , , the number of units of each molecule in the initial carbonated sugar water solution.
• The second line contains four integers , , , representing the photosynthesis reaction: the leaf can consume units of carbon dioxide and units of water to produce units of sugar and units of oxygen.
• The third line contains four integers , , , representing the respiration reaction: the fish can consume units of sugar and units of oxygen to produce units of carbon dioxide and units of water.

Output Specification

For each data set, output the maximum number units of oxygen that can be produced using the system.

Sample Input (Two Datasets Shown)

4 4 4 4
2 1 1 1
2 1 1 1
3 4 4 4
2 2 1 2
2 1 1 1

Sample Output

6
7

Explanation for Sample Dataset

In case one, photosynthesizing twice gives you 6 oxygen. In case two, respiring once gives you enough carbon dioxide to photosynthesize twice, resulting in a total of 7 oxygen.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org