Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.9 kB
5
Indexable
Never
using System;

namespace Banknoty
{
    internal class Program
    {
        public static void binarnie(int[][] tab, int l, int p)
        {
            int[][] banknoty = new int[][];
            int pivot = tab[(l + p) / 2].GetValue;
            int i;
            int j;
            do
            {
                while (tab[i][j].GetValue > pivot)
                {
                    i++;
                }
                while (tab[j].value < pivot)
                {
                    j--;
                }
                if (i <= j)
                {
                    int pom = 0;
                    pom = tab[i][j];
                    tab[i] = tab[j];
                    tab[j] = pom;
                    i++;
                    j--;
                }
            } while (i <= j);
            if (j > l)
                binarnie(tab, l, j);
            if (i < p)
                binarnie(tab, i, p);
        }
        public static int zamiana(int[][] tab, int k, int[] uzywane)
        {
            int wynik = 0;
            for (int i = 0; i < tab[][]; i++)
            {
                int m = Math.Min(k / tab[i], tab[j]);
                if (m != 0)
                {
                    wynik += m;
                    k -= m * tab[][];
                    tab[i] = m;
                }
            }
            return wynik;
        }
        static void Main(string[] args)
        {
            int n = Console.ReadLine();
            int[] value = new int[n];
            int[] ilosc = new int[n];
            int[] used = new int[n];
            int[][] tab = new int[][];
            int k = Convert.ToInt32(Console.ReadLine());
            binarnie(tab, 0, n - 1);
            Console.WriteLine(zamiana(tab, k, used));
            
        }
    }
}