Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
Already signed up?
New to KöMaL?

Problem I. 226. (December 2009)

I. 226. Due to economic reasons, the management of a certain company has decided to use some large capacity printers instead of many smaller printers. Larger printers can handle more complex tasks and they are faster and cheaper. A severe drawback is however that sometimes one should wait if several colleagues want to print simultaneously.

In order to minimize loss of printing time, they have installed two identical paper trays in the printer. (The printer switches between these trays automatically and instantaneously. Empty trays are immediately refilled.)

Incoming printing requests of a particular day have been recorded in the file feladat.txt in chronological order. The first number in the first line of this file is the number of seconds required for the printer to print a single page, while the second number is the capacity of a paper tray. The following lines describe the printing queue: the first 3 numbers in each line refer to the time (hour, minute, second) of the incoming printing request, then the number of pages to be printed (at most 100) and the owner are listed. We know that the company has at most 24 employees.

For example,

feladat.txt

3 500      
8 21 11 30 Anna
8 22 24 3 Eszter
8 22 26 10 Dominik
9 4 0 100 Anna
...        

The fourth row in the example feladat.txt says that Dominik wanted to print 10 pages at 8:22:26. We also see that this task required 30 seconds.

Create your program nyomtat to solve the following exercises. (Your program should process each correct input file.) Display the number of each question before solving it. If your program needs user input, print the corresponding message clearly. (In the second task, for example, ``2nd task: Please enter the name of an employee.'') You may omit diacritical marks.

1. Read the file feladat.txt and use that information to solve the following questions. (If, for some reasons, the file can not be read, enter 10 lines manually and use that data in the following.)

2. Ask the user to enter the name of an employee, then display on the screen when that employee issued a printing request. Each request should appear in different lines in hour:minute:second format.

3. Create a summary of the number of printing requests in a given hour. Each line of your output should contain the hour and the number of printing requests. Ignore those hours when there was no printing.

4. List the names of those people who already printed before 9 o'clock. Names should appear alphabetically and separated by a space.

5. List those printing tasks during which switching between paper trays was necessary. The number of those tasks should appear on the screen separated by a space.

6. Create a summary for each printing task by using the following information: time of incoming printing request, the time when the printer started and finished printing that task, further, the owner of the task. These data should be written to the file kesz.txt (each task in a separate line).

kesz.txt

8 21 11 8 21 11 8 22 41 Anna
8 22 24 8 22 41 8 22 50 Eszter
8 22 26 8 22 50 8 23 20 Dominik
9 4 0 9 4 0 9 9 0 Anna
...                  

The source code (i226.pas, i226.cpp, ...) together with a short documentation (i226.txt, i226.pdf, ...) -- also describing which developer environment to use for compiling, further a brief description of your solution -- should be submitted in a compressed file (i226.zip). feladat.txt

(10 pont)

Deadline expired on January 11, 2010.


Sorry, the solution is available only in Hungarian. Google translation

A nyomtatással kapcsolatos érettségi feladat KöMaL szinten a könnyűek közé tartozik, mégis csupán egyetlen tökéletes megoldás született. Ez azért is meglepő, mert a hibák többsége a mintaként megadott bemeneti fájl áttanulmányozásával kiszűrhető lett volna.

A megoldókat arra buzdítjuk, fordítsanak nagyobb figyelmet a program tesztelésére, vizsgálják meg, hogy legaláb a mintabemenetre helyes eredményt ad-e a program. Az otthoni munka során erre biztosan van idő, szemben az érettségivel, amikor kb. 90 perc áll rendelkezésre.

A megoldók fele már a beolvasás során hibázott. Az utolsó értékes adatsort sorvégjel zárja. A hibázók ezen sorvégjel után is "olvastak" adatot és ez el is raktározták. Érdemes erre figyelni, mert a programozási versenyeken, de akár érettségin is felmerülhet hasonló probléma. Ennek a hibának a hatása leginkább a statiszika készítése során szúrhatott volna szemet, amikor megjelent egy 0 órás feladat is. Többeknél ezt egy másik hiba (0 óra vizsgálatának elhagyása) elfedte.

A 9 óra előtti nyomtatási feladat vizsgálata során többen nem fordítottak kellő figyelmet a ciklushatárok megválasztására, így a rendezés vagy a megjelenítés nem terjed ki minden elemre, esetleg túlnyúlt a tömbhatáron.

Az utolsó feladat megoldása során sokan túlzottan bonyolult módon dolgoztak, leginkább azért, mert az adatszerkezetet nem megfelelően választották meg. Ebben a részfeladatban nagy előny jelent, ha az időadat nem három, hanem egyetlen, másodperc formában megadott értékként szerepel. Nem kell dönteni az egyben vagy külön tárolás között, nyugodtan használható egyszerre mindkettő. A memóriával ugyan nem, de a programsorok számával és a megoldásra felhasznált idővel mindenképpen spórolunk.

Néhányan figyelmetlenségből vétettek a formai szabályok ellen, a 9 óra előtti nyomtatásoknál nem szóközzel, hanem sorvégjellel választották el az értékeket, míg az utolsó feladatban nem jelenítették meg a dolgozó nevét.


Statistics:

10 students sent a solution.
10 points:Szabó 928 Attila.
9 points:Balla Attila, Barta 111 János, Horváth 135 Loránd.
8 points:5 students.
7 points:1 student.

Problems in Information Technology of KöMaL, December 2009