75072024-01-09 11:47:01TortelliniJrSípálya (55 pont)csharpTime limit exceeded 21/55486ms28536 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Keses
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] inp2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long loc;
            long locmax;
            long min = int.MaxValue;
            for (int i = inp1[1] - 1; i < inp1[0]; i++)
            {
                locmax = 0;
                loc = 0;
                for (int u = 0; u > -inp1[1]; u--)
                {
                    locmax = Math.Max(locmax, inp2[u + i] + u);
                    //Console.WriteLine("f" + locmax);
                }
                for (int u = 0; u > -inp1[1]; u--)
                {
                    loc += inp2[u + i] - (locmax - u);
                    //Console.WriteLine("g" + loc);
                }
                if (-loc < min)
                {
                    min = -loc;
                }
            }
            Console.WriteLine(min);
            Console.ReadLine();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base21/55
1Accepted0/030ms22072 KiB
2Accepted0/030ms22744 KiB
3Accepted2/235ms23608 KiB
4Accepted2/235ms23968 KiB
5Accepted2/237ms24136 KiB
6Accepted2/237ms23992 KiB
7Accepted3/337ms24292 KiB
8Accepted1/175ms26032 KiB
9Accepted1/182ms26428 KiB
10Accepted1/190ms26844 KiB
11Accepted1/1120ms26852 KiB
12Accepted1/1118ms27004 KiB
13Accepted1/1223ms27616 KiB
14Accepted2/2248ms27908 KiB
15Accepted2/2119ms27592 KiB
16Time limit exceeded0/2472ms25984 KiB
17Time limit exceeded0/2474ms26116 KiB
18Time limit exceeded0/2462ms26180 KiB
19Time limit exceeded0/3462ms26100 KiB
20Time limit exceeded0/2481ms26648 KiB
21Time limit exceeded0/2477ms26080 KiB
22Time limit exceeded0/2465ms26728 KiB
23Time limit exceeded0/2477ms26928 KiB
24Time limit exceeded0/2462ms28088 KiB
25Time limit exceeded0/2474ms27168 KiB
26Time limit exceeded0/2469ms27544 KiB
27Time limit exceeded0/2481ms28104 KiB
28Time limit exceeded0/3469ms28068 KiB
29Time limit exceeded0/3469ms28144 KiB
30Time limit exceeded0/3486ms28536 KiB