59312023-10-05 20:59:09Global2HuNVállalkozócsharpRuntime error 0/4016ms3204 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace mekkelek
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader sr = new StreamReader("be2.txt");
            string[] lsor = sr.ReadLine().Split();
            int napszam = int.Parse(lsor[0]);
            int rendelesszam = int.Parse(lsor[1]);
            int[] napiteljesites = new int[napszam];
            lsor = sr.ReadLine().Split();
            for (int i = 0; i < napszam; i++)
            {
                napiteljesites[i] = int.Parse(lsor[i]);
            }
            List<int> hatarido = new List<int>();
            for (int i = 0; i < rendelesszam; i++)
            {
                hatarido.Add(int.Parse(sr.ReadLine()));
            }
            sr.Close();
            hatarido.Sort();
            int munkavegzes = 0;
            for (int i = 0; i < rendelesszam; i++)
            {
                for (int j = 0; j < napszam; j++)
                {
                    if (napiteljesites[j] > 0 && hatarido[i] >= j+1)
                    {
                        munkavegzes++;
                        napiteljesites[j]--;
                        hatarido[i] = 0;
                    }
                }
            }
            Console.WriteLine(munkavegzes);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Runtime error0/014ms2948 KiB
2Runtime error0/014ms2920 KiB
3Runtime error0/214ms3120 KiB
4Runtime error0/214ms2904 KiB
5Runtime error0/214ms3072 KiB
6Runtime error0/214ms2944 KiB
7Runtime error0/214ms2856 KiB
8Runtime error0/214ms3092 KiB
9Runtime error0/214ms2836 KiB
10Runtime error0/214ms2912 KiB
11Runtime error0/214ms2932 KiB
12Runtime error0/216ms2948 KiB
13Runtime error0/214ms3204 KiB
14Runtime error0/214ms2660 KiB
15Runtime error0/216ms3068 KiB
16Runtime error0/214ms2924 KiB
17Runtime error0/214ms2984 KiB
18Runtime error0/214ms2780 KiB
19Runtime error0/214ms2956 KiB
20Runtime error0/214ms3092 KiB
21Runtime error0/214ms2996 KiB
22Runtime error0/216ms3148 KiB