Διάρκεια Διαγωνισμού: 3 ώρες Απαντήστε όλες τις ερωτήσεις Μέγιστο Βάρος (20 Μονάδες) Δίνεται ένα σύνολο από N σφαιρίδια τα οποία δεν έχουν όλα το ίδιο βάρος μεταξύ τους και ένα κουτί που αντέχει μέχρι 500 γραμμάρια. Να γράψετε ένα πρόγραμμα το οποίο υπολογίζει πόσο είναι το μέγιστο βάρος σφαιριδίων που μπορούμε να τοποθετήσουμε στο κουτί χωρίς να υπερβούμε το πιο πάνω όριο. Είσοδος Από το πληκτρολόγιο, δίνετε στη πρώτη γραμμή εισόδου ένας θετικός ακέραιος αριθμός Ν (όπου 0 < Ν < 0). Στην επόμενη γραμμή υπάρχουν Ν θετικοί ακέραιοι αριθμοί, που αντιπροσωπεύουν το βάρος του κάθε σφαιριδίου. Έξοδος Στην οθόνη, σε μια γραμμή εκτυπώστε το μέγιστο βάρος σφαιριδίων που μπορούμε να τοποθετήσουμε χωρίς να υπερβούμε το όριο των 500 γραμμαρίων. 20 50 40 30 20 40 30 40 40 50 30 40 30 40 70 80 50 60 60 60 60 500 50 300 400 700 800 550 600 600 60 600 460
Competition Duration: 3 hours Answer all questions Maximum Weight (20 Points) You are given a group of N spheres, not necessarily having the same weight a box that can take up to 500 grams. Write a program that calculates the maximum weight of spheres we can place in the box without exceeding the above limit. Input From the keyboard, you are give on the first line a positive integer number Ν (where 0 < Ν < 0). On the next line there are Ν positive integer numbers, who represent the weight of each sphere. Output On the screen, in one line print the maximum weight of spheres that can be placed in the box without exceeding the 500 grams limit. 20 50 40 30 20 40 30 40 40 50 30 40 30 40 70 80 50 60 60 60 60 500 50 300 400 700 800 550 600 600 60 600 460
T9 (35 Μονάδες) Σε ένα τυπικό τηλέφωνο, οι αριθμοί 1-9 αντιστοιχίζονται εξής ομάδες γραμμάτων: 1: κενό 2: ABC 3: DEF 4: GHI 5: JKL 6: MNO 7: PQRS 8: TUV 9: WXYZ Χρησιμοποιώντας το πληκτρολόγιο του τηλεφώνου, μπορούμε να γράψουμε κάποια λέξη εισάγοντας τα ψηφία που αντιστοιχούν με το κάθε γράμμα της λέξης. Για παράδειγμα η λέξη words αντιστοιχεί με τον αριθμό 96737. Να γράψετε ένα πρόγραμμα το οποίο δέχεται σαν είσοδο ένα αριθμό και με τη χρήση ενός αρχείου/λεξικού (lex.in) παρουσιάζει όλες τις λέξεις από το αρχείο οι οποίες περιέχουν ολόκληρο και αναλλοίωτο τον αριθμό εισόδου οπουδήποτε μέσα στην αντιστοιχία τους. Είσοδος Από το πληκτρολόγιο, δίνετε σε μία γραμμή εισόδου ένας θετικός ακέραιος αριθμός Ν (όπου το μήκος του Ν είναι το πολύ 18 ψηφία και κάθε ψηφίο είναι ανάμεσα στο 2-9 συμπεριλαμβανομένων. Το αρχείο lex.in περιέχει σε κάθε γραμμή μια λέξη. Κάθε λέξη έχει μέγιστο μήκος 18 γράμματα. Έξοδος Στην οθόνη, εκτυπώστε όλες τις λέξεις οι οποίες περιέχουν οπουδήποτε στην αριθμητική αντιστοιχία τους τον αριθμό εισόδου. Να εκτυπώσετε μία σε κάθε γραμμή. Αν δεν βρεθεί καμία, εκτυπώστε No Match. 22222 No Match 3333 626
T9 (35 Points) On a typical phone, the numbers 1-9 are matched with following groups of letters: 1: space 2: ABC 3: DEF 4: GHI 5: JKL 6: MNO 7: PQRS 8: TUV 9: WXYZ Using the keyboard of the telephone, we can write any word by entering the digits that match each letter of the word. For example, the word words matches the number 96737. Write a program that accepts as input a number and using a file/dictionary (lex.in) and it presents all words from the file that contain the complete and unchanged input number as part of their matching number. Input From the keyboard, you are given in one input line a positive integer number Ν (where the length of Ν is at most 18 digits. Each digit is between 2-9, both values inclusive. The file lex.in contains on each line one word. Every word has maximum length 18 letters. Output On the screen, print all words that contain in their matching number the input number. Print one on each line. If none is found, print No Match. 22222 No Match 3333 626
Ανθρακωρύχος (45 Μονάδες) Ένας ανθρακωρύχος έχει παγιδευτεί σε ένα ορυχείο. Μαζί του έχει ένα PDA με τον ανανεωμένο χάρτη του ορυχείου και Ν ράβδους δυναμίτη. Να γράψετε ένα πρόγραμμα το οποίο με τη χρήση του χάρτη (map.in) υπολογίζει μια διαδρομή για να βγει έξω ο ανθρακωρύχος ανατινάζοντας βράχια όποτε κρίνει σκόπιμο χρησιμοποιώντας τον ελάχιστο αριθμό ράβδων δυναμίτη. Είσοδος Από το πληκτρολόγιο, δίνετε στη πρώτη γραμμή εισόδου ένας θετικός ακέραιος αριθμός Ν (όπου 0 < Ν < 00). Από το αρχείο map.in, δίνετε ο χάρτης όπου: στην πρώτη γραμμή δίνονται δύο θετικοί ακέραιοι αριθμοί i,j (όπου 5 < i,j < 0). Στις επόμενες i γραμμές περιέχονται j θετικοί ακέραιοι αριθμοί. Κάθε αριθμός, αντιπροσωπεύει τον αριθμό των ράβδων δυναμίτη που απαιτούνται για να περάσει από τη συγκεκριμένη θέση ο ανθρακωρύχος. Ξεκινώντας την αρίθμηση από i=0 και j=0, η αρχική θέση του ανθρακωρύχου είναι πάντα η [1,1] και συμβολίζεται από την τιμή 01. Η έξοδος είναι πάντα στη θέση [i- 1,j-1] και συμβολίζεται από την τιμή 02. Έξοδος Στην οθόνη, στην πρώτη γραμμή εκτυπώστε τον ελάχιστο αριθμό ράβδων δυναμίτη που απαιτούνται για να βγει έξω ο ανθρακωρύχος (Πάντα θα υπάρχει τρόπος να βγει έξω ο ανθρακωρύχος). Στην επόμενη γραμμή εκτυπώστε τις συντεταγμένες των σημείων όπου τοποθετήθηκε έστω και μία ράβδος δυναμίτη. 2 5 5 5 8 6 0 0 0 0 0 0 0 0 0 0 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3 2 1 4 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 2 0 0 1 1 0 0 0 0 0 1 0 0 1 02
Coalminer (45 Points) A coalminer is trapped in a mine. With him he has a PDA with the updated map of the mine and Ν sticks of dynamite. Write a program that using the map (map.in) calculates a path to get the coalminer out by blowing away rocks whenever necessary, and using at the same time the minimum quantity of dynamite sticks. Input From the keyboard, you are given on the first input line a positive integer number, Ν (where 0 < Ν < 00). From the file map.in, you are given the map, where: on the first line you are given two positive integer numbers i,j (where 5 < i,j < 0). On the next i lines there are j positive integer numbers. Each number represents the number of dynamite sticks needed to be used by the coalminer in order to go through. Starting with numbering of i=0 and j=0, the initial position of the coalminer is always [1,1] and the value 01 is used as a symbol. The exit is always on the position [i-1,j-1] and the value 02 is used as a symbol. Output On the screen, on the first line print the minimum amount of dynamite sticks needed for the coalminer to get out (There will always be a way for the coalminer to get out). On the next line print the coordinates of the points where at least one dynamite stick was used. 2 5 5 5 8 6 0 0 0 0 0 0 0 0 0 0 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3 2 1 4 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 2 0 0 1 1 0 0 0 0 0 1 0 0 1 02