155082025-02-20 09:31:07DominikMaximális szorzat (50 pont)csharpRuntime error 0/5014ms3068 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NT_gyak
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int N = int.Parse(data[0]);
            int K = int.Parse(data[1]);
            int b = int.Parse(data[2]);
            int negatives = 0;
            string[] data2 = Console.ReadLine().Split(' ');
            List<int> numbers = new List<int>();
            for (int i = 0; i < N; i++)
            {
                numbers.Add(int.Parse(data2[i]));
                if (numbers[numbers.Count-1]<0)
                {
                    negatives++;
                }
            }
            numbers.Sort();
            for (int i = b; i < negatives; i++)
            {
                K += numbers[i];
                numbers[i] = 0;
            }
            while (K>0)
            {
                numbers.Sort();
                numbers[b]++;
                //Console.WriteLine(numbers[b+1]+" "+(b+1));
                K--;
            }
            int szorzat = 1;
            for (int i = 0; i < N; i++)
            {
                szorzat *= numbers[i];
            }
            Console.WriteLine(szorzat);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/014ms2628 KiB
2Runtime error0/014ms2768 KiB
3Runtime error0/014ms2908 KiB
4Runtime error0/014ms2824 KiB
5Runtime error0/014ms2784 KiB
6Runtime error0/214ms2944 KiB
7Runtime error0/214ms2804 KiB
8Runtime error0/214ms2824 KiB
9Runtime error0/214ms2504 KiB
10Runtime error0/214ms2880 KiB
11Runtime error0/214ms2636 KiB
12Runtime error0/114ms2744 KiB
13Runtime error0/114ms3032 KiB
14Runtime error0/114ms2796 KiB
15Runtime error0/114ms2768 KiB
16Runtime error0/114ms2548 KiB
17Runtime error0/114ms2504 KiB
18Runtime error0/114ms2736 KiB
19Runtime error0/114ms2744 KiB
20Runtime error0/114ms2676 KiB
21Runtime error0/114ms3068 KiB
22Runtime error0/114ms2780 KiB
23Runtime error0/114ms2860 KiB
24Runtime error0/114ms2680 KiB
25Runtime error0/214ms2524 KiB
26Runtime error0/214ms2644 KiB
27Runtime error0/214ms2860 KiB
28Runtime error0/114ms2740 KiB
29Runtime error0/214ms2776 KiB
30Runtime error0/114ms2804 KiB
31Runtime error0/114ms2620 KiB
32Runtime error0/214ms2860 KiB
33Runtime error0/214ms2872 KiB
34Runtime error0/114ms2696 KiB
35Runtime error0/214ms2772 KiB
36Runtime error0/214ms2796 KiB
37Runtime error0/214ms2884 KiB
38Runtime error0/214ms2776 KiB
39Runtime error0/114ms2840 KiB