ONI 97, Timisoara, martie 1997
Ziua 2

     Problema 4 (Vinuri bune)
     La un depozit specializat din Recas sosesc, pe rand, n clienti care solicita 
fiecare o cantitate data de Cabernet. In butoiul din magazinul de deservire 
(considerat de capacitate nelimitata) nu se gaseste initial nici o picatura de 
vin. Dan Septica, administratorul depozitului, are un algoritm propriu de deservire 
a clientilor: in functie de ceea ce are in butoi, dar si de inspiratia de moment, 
el poate sa raspunda :
Va ofer intreaga cantitate cu cea mai mare placere !
sau
Nu va pot oferi acum ceea ce doriti, mai reveniti cu solicitarea altadata!
     Pe clientul servit il elibereaza de grija banilor corespunzatori costului 
licorii cumparate, iar pe cel refuzat il saluta politicos si are grija ca, 
imediat ce a plecat clientul, sa coboare si sa aduca in butoiul din magazin 
exact cantitatea solicitata de clientul respectiv (cel ce nu a fost servit).
Clientii sunt restaurante de lux si nu cumpara mai mult de 1 hectolitru.
Cunoscind cele n cantitati cerute de clienti , sa se determine un mod de a 
raspunde solicitarilor astfel incat, in final, cantitatea de vin vanduta sa fie 
maxima.
Intrare: Din fisierul de intrare CERERI.IN se citesc:
- de pe prima linie , n - numarul de clienti (n<=1000);
- de pe a doua linie n numere naturale, separate prin spatiu, reprezentand 
cantitatile (in litri) cerute de clienti, in ordinea sosirii lor.
Iesire: Programul trebuie sa scrie in fisierul de iesire VANZARI.OUT cantitatea 
vanduta (tot in litri).
Exemplu:
CERERI.IN:
4
5 3 4 2
VANZARI.OUT
6
Interpretare:
        Actiunile lui Septica sunt: refuza primul client si pune 5 litri in 
butoi, il refuza pe al doilea si mai pune inca 3 litri in butoi, iar pe urmatorii 
doi clienti ii serveste , realizand o vanzare de 6 litri.
================================
Input 1:
10
0 1 0 2 0 4 8 16 32 64
===========================
Input 2:
20
45 39 23 98 62 22 96 93 83 32 41 91 60 66 77 29 59 13 25 61
=============================
Input 3:
50
70 72 88 90 72 11 34 86 38 50 100 22 94 11 88 97 42 92 19 24 80 45 47 40 63 51 93 65 71 38 55 91 83 88 15 49 57 39 76 71 76 78 62 50 21 60 86 79 61 29
=============================
Input 4:
200
37 32 20 22 9 16 9 98 39 88 28 61 5 2 62 54 43 15 48 40 7 79 37 37 68 25 35 59 40 96 80 74 72 81 57 93 33 69 47 65 92 99 48 40 60 3 38 17 44 43 58 100 44 5 25 17 77 98 20 89 16 68 98 38 82 23 19 82 24 40 6 64 63 85 62 84 8 76 15 63 55 76 65 38 24 72 64 77 8 10 36 60 28 71 32 55 21 4 71 7 11 67 9 3 33 35 50 78 2 72 74 84 72 81 51 41 9 77 78 29 61 47 51 97 35 91 39 96 78 65 56 70 40 58 32 50 70 82 18 37 57 58 97 80 30 22 69 76 73 89 45 43 25 39 58 56 61 31 77 40 83 42 95 55 67 91 3 29 33 5 98 10 54 24 68 59 3 58 54 93 9 45 93 47 78 65 78 28 94 16 7 73 6 67 82 29 65 13 100 20
=============================
Input 5:
600
35 13 91 23 77 95 23 10 57 80 71 46 27 30 66 11 88 28 97 79 32 85 12 76 89 48 48 63 14 60 89 70 9 31 93 85 56 18 49 78 99 23 55 21 19 62 11 27 75 62 89 10 9 83 14 58 43 89 63 59 6 91 79 21 79 52 45 81 43 29 72 98 64 79 95 60 51 67 76 66 77 41 67 53 46 78 71 84 41 94 14 18 89 95 15 16 30 99 1 75 85 49 35 79 30 25 22 4 54 88 26 34 51 38 25 62 48 75 54 90 6 65 46 43 26 77 61 62 41 40 44 61 91 21 83 37 13 35 42 73 74 41 76 91 42 69 82 23 81 3 34 22 100 98 79 23 97 13 33 25 75 91 80 67 38 6 65 96 71 79 39 73 70 11 90 57 85 95 85 54 79 7 83 31 24 85 9 28 91 49 98 29 87 10 46 52 63 87 29 86 99 22 73 89 17 56 88 10 5 24 7 7 36 55 77 78 18 13 9 13 15 100 75 55 21 2 1 10 70 65 26 47 31 21 81 92 2 1 40 84 14 7 46 67 13 35 92 31 60 64 30 14 89 54 34 41 9 17 34 67 27 65 6 28 40 34 75 36 26 43 65 72 14 43 29 51 34 56 5 67 68 17 98 50 46 67 97 85 72 50 59 82 63 29 25 81 40 11 44 55 7 50 37 26 97 75 9 10 88 44 96 70 100 44 15 23 35 66 37 42 22 43 17 45 75 20 36 72 82 96 57 68 73 57 80 53 42 90 64 25 26 50 45 31 53 14 61 18 18 50 80 22 58 80 74 82 22 23 97 69 57 32 54 77 69 74 70 20 19 23 100 13 65 42 35 50 60 90 92 3 70 85 2 98 69 94 25 49 26 42 66 52 94 54 56 66 52 78 34 52 86 53 50 23 85 10 50 34 97 32 41 27 81 10 30 96 32 61 91 37 76 1 2 6 62 94 57 1 96 17 51 30 91 3 72 35 31 62 76 98 77 93 17 26 57 34 46 4 15 3 18 68 23 45 67 27 70 80 32 33 86 11 51 93 69 44 51 65 10 29 99 66 52 24 6 14 14 34 80 63 73 87 80 99 81 38 23 15 63 33 28 93 23 47 17 40 47 89 99 58 97 61 8 67 14 70 69 92 86 61 14 77 52 25 77 16 32 67 36 80 29 71 72 98 20 85 81 26 38 100 55 96 26 29 94 42 93 70 46 39 19 34 83 4 85 76 37 42 19 37 70 41 92 8 64 45 7 54 30 64 47 82 84 90 99 23 47 36 59 60 53 22 73 41 74 62 96 42 12 31 48 74 95 22 17 50 85 16 25 55 100 25 66 86 78 86 81 55 63 3
==============================
Input 6:
600
93 91 95 95 92 96 100 95 97 91 94 94 98 98 94 93 95 92 94 92 94 91 94 96 99 99 99 95 97 98 91 99 93 97 93 94 100 94 96 93 92 100 95 95 97 93 98 98 93 92 92 97 98 91 94 92 93 95 98 94 98 92 95 99 98 97 94 96 93 92 92 98 98 100 98 97 93 98 94 100 96 99 100 93 93 100 97 93 92 99 94 100 95 95 96 99 93 94 98 91 92 94 97 93 94 100 93 94 98 96 98 91 99 93 100 97 92 92 97 98 94 97 96 91 96 95 91 93 92 97 95 96 99 95 97 99 92 98 93 92 98 95 96 94 99 93 92 100 96 95 96 100 91 93 95 93 97 94 99 94 98 92 91 95 94 95 91 96 98 96 92 97 97 94 92 96 99 91 94 91 98 99 96 95 98 94 92 97 97 99 98 92 99 92 98 93 93 97 94 99 92 94 96 93 92 91 93 96 91 100 98 91 100 91 97 99 93 96 94 98 96 98 92 96 96 95 96 95 97 100 94 95 96 98 94 97 91 93 100 96 95 95 95 98 99 99 93 94 98 91 97 96 93 94 100 91 93 96 91 97 93 93 93 93 95 91 96 95 91 94 99 99 99 91 94 96 97 99 91 92 98 96 100 99 99 97 97 100 98 96 98 92 93 93 91 94 98 100 95 91 100 91 92 95 91 96 98 91 92 95 93 91 100 96 94 96 96 96 99 95 92 95 97 98 97 98 99 95 99 92 94 93 99 94 92 91 94 97 91 97 98 100 97 97 97 92 92 95 96 97 100 93 97 95 97 98 99 93 93 91 92 97 91 96 97 98 92 91 93 96 100 92 95 99 94 94 92 92 99 94 91 99 95 91 94 98 92 91 99 93 95 93 96 94 94 98 95 92 92 98 99 93 92 99 98 91 99 93 95 98 92 95 96 96 98 93 91 100 93 91 93 100 92 94 94 97 94 94 95 98 95 93 92 92 100 97 99 97 95 92 95 91 91 94 96 93 92 91 93 97 91 94 92 98 92 99 100 97 92 92 99 93 91 93 100 97 93 100 94 97 95 100 99 98 95 92 95 93 91 93 97 96 91 96 94 97 91 96 94 91 95 98 92 97 100 95 98 92 99 96 98 98 99 99 92 100 99 98 91 100 97 97 94 96 95 96 92 98 98 95 97 93 98 99 96 94 93 100 93 97 92 100 98 99 92 93 98 99 98 92 99 92 93 96 96 97 95 96 96 100 98 91 94 92 100 94 97 92 99 99 97 98 92 100 98 94 92 99 99 98 98 94 98 92 100 94 93 91 97 98 100 100 98 99 95 95 93 98 91 93 96 93 100 95 98 91 100 98 92 98
=================================
Iesire 1:
0
#5
=========================
Iesire 2:
557
#5
==========================
Iesire 3:
1509
#10
=========================
Iesire 4:
5041
#10
===========================
Iesire 5:
15503
#10
============================
Iesire 6:
28603
#10
===========================
